Why Stateless Architecture is better than Stateful Architecture when scaling web applications
A stateful and stateless server has some key differences. A stateful server remembers client data from one request to the next. A stateful server retain states and needs to remember the past and apply it to current operations.
The following image shows how a stateful architecture is designed.
From the diagram Client A data are stored in server 1. For Client A to be authenticated all http requests must be routed to server 1. Client B data are stored in server 2. For Client B to be authenticated all http requests must be routed to server 2 if a request is sent to server 1 or any other server the request will fail because those other servers does not contain Client B information. Same goes for Client A, Client C and Client D.
This makes it very difficult to scale because of every request from the same client must be routed to the same server. Adding and removing servers are very difficult with this approach and it is difficult to handle if your server should fail.
STATELESS SERVERS
In stateless architecture http request from a user can be sent to any web server which fetches data from the same data store. Below is an image of a stateless architecture.
The stateless system is more robust and scalable and it is also more simple than the stateful system.
The added flexibility of autoscaling the web servers on the application layer depending on the network traffic allows you to not worry about overhead.