Fundamentalsstatelessstatelessnessstatefulshared-nothing

Stateless service

Definition

A stateless service holds no per-client state in local memory or disk across requests; each request carries what is needed (a token, IDs), and lasting state lives in a database, cache or the client.

In practice

Statelessness is what makes horizontal scaling and failover easy: a load balancer can send each request anywhere, autoscaling can add or remove instances at will, and a crashed instance loses nothing. Session data moves to a shared store such as Redis or into a signed token, and uploads go to object storage rather than local disk.

The state does not disappear, it moves, and the shared store now needs its own scaling and availability. Each request may pay an extra hop to fetch it. Some components are stateful by nature (databases, WebSocket servers holding open connections) and need partitioning, replication or affinity instead of pretending otherwise.

Example

Moving sessions from in-memory maps to Redis lets a shop run 12 interchangeable API instances behind a round-robin balancer, where before users were logged out whenever their instance restarted.