Stateless web tier
Play this lessonThis lesson comes with an interactive animation you can break, a live-code challenge and a chapter quiz.To scale the web tier horizontally, we must move state (like user session data) out of the web servers.
🔒 Stateful server
Remembers client data from one request to the next. User A's session lives on Server 1, so every request from User A must go to Server 1. Load balancers can do this with sticky sessions, but adding or removing servers gets hard and failures lose sessions.
🔓 Stateless server
Keeps no client data. State lives in a shared data store (a relational database, Memcached/Redis, or NoSQL). Any server can handle any request. Simpler, more robust, more scalable.
Once the web tier is stateless, autoscaling is easy: add or remove servers automatically based on traffic.
Key takeaways
- Keep the web tier stateless: store sessions in a shared store.
- Stateless servers are interchangeable, which makes autoscaling possible.