Scaling Patterns

Statelessness, load balancing, autoscaling signals, pagination, batching and streaming — the specific techniques, and the problem each one is a response to.

Making an Existing Service Stateless

The inventory, the migration order and the verification — turning a service that works on one instance into one where any instance can serve any request.

Q · I have a service that assumes it is the only instance. What is the actual sequence of changes that makes it safe to run several?
Horizontal vs Vertical Scaling

A bigger machine is simpler and has a ceiling; more machines have no ceiling and require statelessness, a load balancer and coordination you did not have before.

Q · The service is at capacity. Do I make the machine bigger or add more of them?
Load Balancing, From the Backend's Side

What your application owes the thing distributing traffic to it — an honest health signal, aligned timeouts, and no assumption about which instance gets what.

Q · What does my backend have to do to be distributed across correctly, and what can the load balancer not fix?
Sticky Sessions

Pinning a client to one instance buys cache locality and hides instance-local state — and it costs you failover, rebalancing and clean scale-down.

Q · When is it right to send a user's requests to the same instance every time, and what does that cost?
Autoscaling a Backend

Choosing a signal that actually reflects load — and understanding why CPU is the wrong one for a service that spends its time waiting.

Q · What should the number of instances be a function of, and how fast can that number honestly change?
Read Replicas From the Application

Routing reads to a replica multiplies read capacity and introduces a window where the application can read data that is older than what it just wrote.

Q · Which reads can safely go to a replica, and what breaks when they go to the wrong one?
Pagination That Survives a Large Table

Offset pagination is easy and gets quadratically more expensive with depth; keyset pagination is cheap at any depth and gives up random access to page N.

Q · How do I let a client walk a large result set without the last page costing more than the first?