Load balancing & horizontal scaling
Spread traffic across stateless instances and know what stops a service from scaling out.
Scaling vertically means a bigger machine. Scaling horizontally means more machines behind a load balancer. The second needs your service to be stateless: anything a request needs must come from the request itself or from shared storage, not from one instance's memory.
Load balancers distribute with round robin, least connections, or consistent hashing when you want the same key to reach the same node, as with local caches. Health checks remove broken instances automatically.
State is what resists scaling. Sessions, uploads on local disk and in-process caches all pin users to one box. Move them to shared stores and the web tier becomes easy to scale. The database is then the next bottleneck.
Key points
- Stateless services scale by adding instances.
- Health checks and graceful shutdown make deploys and failures invisible.
- Use consistent hashing when locality matters, round robin when it does not.
- After the web tier scales, the database is the next constraint.
Answer these out loud
- 1Your login sessions live in server memory. List what breaks when you add a second instance and fix each.
- 2How does a load balancer decide an instance is unhealthy, and what is the cost of checking too often?
Use this from an agent
Any MCP client, including Grok, can read this lesson. See how to connect.
curl https://engineeros-delta.vercel.app/api/v1/topics/load-balancing-and-scaling