System Design, Infrastructure

Stateless Web Tier

A corgi smiling happily

Now it is time to consider scaling the web tier horizontally. For this, we need to move the state out of the web tier ( for instance, user session data). A good practice is to store session data in persistent storage such as a relational database or NoSQL. Each web server from the cluster can access state data from databases. This is called a stateless web tier.

Stateful architecture

A stateful server and a stateless server have some key differences. A stateful server remembers client data (state) from one request to another. A stateless servers keep no state information.

With stateful, the issue is that every request from the same client must be routed to the same server. This can be done with sticky sessions in most load balancers. However, this adds the overhead. Adding or removing servers is much more difficult with this approach. It is also challenging to handle server failures.

Stateless architecture

HTTP requests can be sent to any server which fetches data from data storage. A stateless system is more straightforward, more robust, and scalable.

After the state data is removed from the web server, auto-scaling of the web tier is easily achieved by adding or removing the server based on traffic load.


Do you have any questions, or simply wish to contact me privately? Don't hesitate to shoot me a DM on Twitter.

Have a wonderful day.
Abhishek 🙏

Subscribe to my newsletter

Get email from me about my ideas, full-stack development resources, tricks and tips as well as exclusive previews of upcoming articles.

No spam. Just the highest quality ideas you’ll find on the web.