System Design Basics: Part 6

If you want to scale your web server horizontally then you should move the state out of web server. If your application stores some state in it then you need to make sure all the request belonging to that state are served by that particular server. For this you would need to implement service to service routing technique based on some condition. For example: If you are getting requests belonging to a particular product then only server ‘1’ should serve those requests as information related to state product is only present on that server. Due to these reasons it is a good practice to store session data in persistent storage such as NoSQL database. 

In stateless architecture the above mentioned problem doesn’t exist as HTTP requests from users can be sent to any web servers, which will fetch the state data from common/shared database/storage. State data will be stored in a shared data store and will be kept out of web servers. Thus, a stateless architecture system is more robust, simpler to understand and implement and most importantly scalable.

If your user requests increase and servers need more resources you can easily enable auto-scale and solve this issue as there’s no dependence of state on any of the server.

Leave a Comment

Your email address will not be published. Required fields are marked *