Scalability: Vertical vs Horizontal
Vertical scaling means adding more CPU, RAM, or disk to a single machine. It is simple — no code changes, no coordination — but has a hard ceiling. The largest cloud instances today have hundreds of vCPUs and tens of TB of RAM. When you hit that ceiling, or when cost becomes prohibitive, you must scale horizontally: add more machines and distribute the load across them.
Horizontal scaling introduces a key problem: stateful applications break because each request can land on a different server. The fix is to move all session state out of the server — into a database or Redis — so every server is identical and any request can go to any instance. This stateless server pattern is the prerequisite for everything else in distributed systems.
Check your understanding
What breaks when you scale stateful servers horizontally?Show answerHide answer
Answer
In-memory sessions — the next request may hit another instance that does not have the session.What is the usual fix?Show answerHide answer
Answer
Externalize session/state (DB or Redis) so every instance is interchangeable.Vertical vs horizontal in one line?Show answerHide answer
Answer
Vertical: bigger machine. Horizontal: more machines behind a balancer.