sessionarchitecturescalabilitystatelessweb-architecture

Does stateless only transfers client's state to somewhere else?


I have spent a whole day understanding what stateless architecture is. I read many posts and answers like

Can My Web App Implement User Login and Remain Stateless?

Pros and Cons of Sticky Session / Session Affinity load blancing strategy?

http://www.quora.com/What-is-stateless-and-statefull-web-architecture

Do I miss something or understand wrongly?

Thank you!


Solution

  • You are correct in that moving your state to a different layer means your application is stateful (there are very few truly stateless applications, mostly only ones doing pure math).

    That doesn't mean individual layers can't be stateless, and those layers that are will scale differently than the stateful layers. The idea is that by making a particular part of the application stateless, you will be able to scale it horizontally, instead of vertically, thus able to respond to many more requests by simply buying more hardware.

    You will still need to scale wherever you push that state to. So if you are are pushing it out to a database, you will need to be able to scale that database accordingly. This works well if you can push it out to a layer that can be scaled cheaply (like memcached).

    It is often the goal to make your business and web layers stateless because they are generally much more expensive to scale than your data-store layers, but this isn't always true. If you have put a lot of load on your data store layer, and very little load on your application or web layers (like a data-driven vs an interaction-driven app, then you will overload your data layer.

    So, like everything else, whether to make your application stateless comes down to "it depends". Generally, stateful business and web layers tend to get overloaded long before data layers do. Especially if you are doing significant OOP.