Scaling / 3 / 5
Stateless servers
A shop API keeps logged-in users in its own memory. It works on one server and breaks the moment you add a second one or restart the first. Where the state should live instead.
- 10 min
- Beginner
- 11 steps
- Servers in service
- 1
- Unexpected logouts
- 0 /min
- Reply p95
- 80 ms
- request
- reply
- redelivery
- duplicate
- lost
Numbers are a model scenario, not measurements
The real request
Browser → App server 1Request
POST /login HTTP/1.1
Host: api.example.com
Content-Type: application/json
{
"email": "u42@example.com",
"password": 1hidden
}
Response
HTTP/1.1 200 OK
Set-Cookie2: hidden
{ "user_id": 3"u_42" }
password· hidden — Sent once, over HTTPS. Hidden here.Set-Cookie· hidden — The session ID. Anyone who has it is logged in as this user, so it is hidden too.user_id— Who logged in. The server remembers it next to the session ID, in its own RAM.
Course: 42 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes