Skip to slide
Chapter 16 · Scaling and Infrastructure
156 / 191

CHAPTER 16 · Scaling and Infrastructure · 2 / 10

Statelessness: the foundation

The single most important property for horizontal scaling is stateless application servers. Each request should be servable by any instance, carrying no in-memory state between requests. Achieve it by:

  • Keeping all durable state in shared stores (database, object storage, cache), not in process memory.
  • Making the agent loop a function of its inputs: it loads context from the database at the start and writes results at the end (Chapters 2, 9), holding nothing between turns.
  • Carrying session/identity in tokens validated per request (Chapter 11), not server-side session memory.

With stateless servers, you scale by adding instances behind a load balancer, and any instance can handle any user.

← → arrow keys work too