Horizontal vs Vertical Scaling
Vertical scaling adds resources to existing machines; horizontal scaling adds more machines to distribute load.
What is the difference between horizontal and vertical scaling?
Scaling is the process of increasing a system's capacity to handle more load. There are two fundamental approaches, each with distinct tradeoffs.
Vertical Scaling (Scale Up)
Adding more resources (CPU, RAM, SSD) to an existing server.
Example: Upgrading a database server from 16 vCPUs / 64 GB RAM to 64 vCPUs / 256 GB RAM.
- ✅ No application changes required - same code runs on bigger hardware
- ✅ No distributed systems complexity (no sharding, no consensus)
- ✅ Strong consistency is easy - single node
- ❌ Physical ceiling - you can only buy so much hardware
- ❌ Single point of failure - if the server dies, the service is down
- ❌ Downtime during upgrades (usually)
- ❌ Cost grows super-linearly - doubling specs often costs 4× more
When it wins: Early-stage systems, stateful databases, when operational simplicity outweighs cost, when the problem is CPU/memory bound (not I/O).
Horizontal Scaling (Scale Out)
Adding more servers to a pool, distributing load across them.
Example: Running 10 web servers behind a load balancer instead of 1 large server.
- ✅ Theoretically unlimited - add servers as needed
- ✅ High availability - losing one node doesn't bring down the service
- ✅ Commodity hardware - cheap servers at scale
- ✅ Easier auto-scaling (cloud: spin up instances on demand)
- ❌ Requires stateless application design - session state can't live on individual servers
- ❌ Distributed systems complexity: CAP tradeoffs, eventual consistency, distributed transactions
- ❌ Harder to debug - issues may only manifest under specific node conditions
When it wins: Stateless web/API services, microservices, when you need 99.99% uptime, at cloud scale.
The Stateless Requirement
For horizontal scaling to work, servers must be interchangeable. That means:
- No in-memory session storage -> move to Redis
- No local file storage -> move to S3 or shared volume
- No local state of any kind a user's next request might need
Cost Curves
Vertical scaling has a convex cost curve - cost per unit of capacity increases as you scale up (enterprise hardware is expensive). Horizontal scaling has a more linear cost curve - each commodity server adds roughly proportional capacity.
Practical Strategy
Most real systems start vertical (simpler) and go horizontal as they grow:
- Start: single server, vertical scale
- Growth: add read replicas for database
- More growth: add app servers behind a load balancer (horizontal web tier)
- High traffic: shard the database horizontally
Auto Scaling
Cloud platforms enable dynamic horizontal scaling: add servers when CPU > 70%, remove them when CPU < 20%. This makes horizontal scaling dramatically more cost-effective than keeping a vertically scaled server provisioned for peak load 24/7.
Interview Angle
Interviewers want to hear: "I'd start with vertical scaling for the database (ACID, simplicity) and horizontal scaling for the stateless API tier from the start." Then explain why - vertical for stateful/consistent parts, horizontal for stateless/scalable parts.