SysDesign study
Offline — showing the cached copy.
Home / Software System Design / 3. Stateless services and sessions

3. Stateless services and sessions

One-liner. If any instance can serve any request, scaling is a number, not a project.

Memorize

  • Keep session state out of the process: JWT (self-contained, hard to revoke) or session store (Redis, revocable).
  • Sticky sessions are a crutch; they break on scale-in and deploy.
  • Shared state lives in: cache (Redis), DB (durable), object store (large blobs).
  • Idempotent startup: instances must join the pool without coordination.
  • Deploys should be rolling; draining connections requires graceful shutdown + LB deregistration delay.
STATELESS FAN-OUT Client LB App 1 App 2 App 3 Shared sessionstore
Stateless fan-out

Trap. Storing uploads on the instance's local disk — the next request lands elsewhere and 404s. Do this. Ask "what breaks if this instance dies right now?" for every piece of state.

Check

Users are logged out randomly after a deploy. The app stores sessions in local memory and runs 4 instances. What is the correct fix?