Scalability Patterns

Difficulty
Importance

The problem

A system designed for its current traffic will eventually face more than it can handle, and the architectural decisions that make scaling easy or painfully hard are made long before that traffic arrives — this topic is about designing for growth deliberately, rather than discovering the bottleneck under pressure.

Why now

Load balancing and auto-scaling already established the infrastructure mechanisms for running many instances of a service; scalability patterns is the architectural discipline of designing services so those mechanisms actually work — which mostly comes down to one property: whether a service can be freely duplicated without breaking anything.

Mental model

The single biggest scalability decision is statelessness: a stateless service keeps no data specific to one instance, so a load balancer can send any request to any instance interchangeably, and adding capacity is as simple as adding more instances. The moment a service holds instance-specific state (an in-memory session, a local file), scaling it horizontally breaks unless that state is deliberately externalized — which is exactly the problem stateless design avoids from the start.

Requires

Used in

Projects

  • Take a service storing session data in local memory, and refactor it to store sessions in a shared external store so any instance can handle any request
  • Explain, for a specific real service, what would break if it were suddenly run as 5 instances behind a load balancer instead of 1, and fix each issue

Examples

  • A service storing user sessions in local memory breaks under load balancing — a user's second request might hit a different instance that's never heard of their session
  • A truly stateless service can be scaled from 2 instances to 20 with zero code changes, because no instance holds anything the others don't already have equal access to

Resources

Mastery checklist