← Lessons

quiz vs the machine

Silver1050

System Design

Horizontal Scaling with Stateless Services

Why keeping no local state lets you add identical servers behind a load balancer at will.

3 min read · intro · beat Silver to climb

The idea

Horizontal scaling means handling more load by adding more machines rather than buying a bigger one. The trick that makes it cheap is keeping each server stateless: it holds no session or user data between requests.

Why stateless matters

  • Any server can answer any request, so a load balancer can route freely.
  • A crashed server loses nothing important, so recovery is just replacing it.
  • You can add or remove instances during a traffic spike without migrating data.

Where the state goes

The state still exists, it just moves to a shared backing store.

  • Session data lives in a shared cache like Redis.
  • Persistent data lives in a database.
  • Files live in object storage.

The servers become interchangeable workers, and the hard problem of holding state is pushed to a few systems built for it.

Key idea

Make the application tier stateless so you can scale it by simply adding identical replicas.

Check yourself

Answer to earn rating on the learn ladder.

1. What makes a stateless service easy to scale horizontally?

2. Where does the state go in a stateless design?