Horizontal vs Vertical Scaling: When to Scale Out vs Scale Up
Fast recall
Quick revision
Core answer
Trade-offs between simplicity (vertical) and resilience/elasticity (horizontal), state's role, and the cost curve.
Treating one as universally better, or assuming horizontal scaling is free (it requires architectural design — statelessness, sharding, distributed coordination).
Discuss diagonal scaling (vertical first then horizontal), sharding strategies for stateful tiers, the cost model (vertical scales superlinearly in cost), and elasticity (horizontal autoscaling vs vertical resize downtime).
Interview-ready guide
Interview answer
Two mental models
Vertical: bigger machine. Same JAR, more CPU/RAM. System is still 'one machine' from the app's perspective. Horizontal: more machines behind a load balancer. System is 'many machines coordinating.'
It's not either-or; modern systems do both — vertical to a comfortable size, then horizontal for growth and resilience.
Vertical strengths
- No code changes. Same JAR, bigger box. Critical for legacy and stateful workloads where 'just shard it' isn't an option
- Lower latency for in-process workloads — bigger CPU caches, fewer hops
- Simpler operations — one instance, one set of logs
- Default for most relational databases
Vertical limits
- Hardware ceiling — largest cloud instance is ~32TB RAM, 224 vCPU; specialty hardware higher but extreme cost
- Single point of failure — one disk dies, you're down
- Superlinear cost — doubling vCPU often more than doubles price; 16xlarge is ~3-4x a 4xlarge, not 4x
- Resize requires downtime — stop-modify-start, 3-15 minutes
- No elasticity — can't scale for a 2h spike
Horizontal strengths
- Effectively unbounded — webscale companies run 100K+ instances of the same service
- Built-in fault tolerance — one dies, LB routes around
- Elastic — autoscale up for spikes, down for quiet; cloud cost optimization
- Roughly linear cost — no big-box premium
- Independent deploys and isolation
Horizontal challenges
- Requires stateless or shardable design
- Distributed system problems appear: CAP trade-offs, partitions, leader election, clock skew
- Operational complexity — service discovery, LB, certificates, logs, distributed tracing
- Cold start and reactive autoscaling — sudden spikes outpace it
- Coordination overhead — distributed locks, consensus, config sync
- Some workloads (heavy joins, in-memory analytics) are hostile to horizontal split
The pragmatic order — diagonal scaling
- 1Make it work on one box — ship monolith, profile bottlenecks
- 2Scale up first — cheap, zero-effort, gets you 10-100x
- 3Make stateless tiers horizontal — push session/state to Redis or DB; LB + autoscale
- 4Keep stateful tiers vertical as long as possible — beefy Postgres + standby + read replicas handle a lot
- 5Shard stateful tier only when you must — hot-shard problems, rebalancing, cross-shard queries are real costs; pick shard key carefully (user_id, tenant_id)
Diagonal scaling: combine vertical (bigger nodes) with horizontal (more nodes). 10-node Cassandra of 16xlarges, not 100 smalls.
Statelessness — the key enabler
Stateless service: any instance can serve any request.
- Store sessions in Redis/DynamoDB, not JVM memory
- Files in S3, not local disk
- In-memory caches are best-effort
- WebSocket needs sticky sessions or sharded handling
LB can use round-robin or P2C. Autoscale freely. Rolling deploys, blue-green, canary all trivial.
Deeper truth: 'horizontal scaling' is mostly 'pushing state down to the next tier.' Eventually you hit a tier (database) that's hard to horizontally scale — sharding becomes the question.
Database scaling patterns
- Vertical first: Postgres/MySQL beefy instance handles tens of thousands of QPS
- Read replicas for read-heavy: leader vertical, N replicas
- Sharding for write throughput: Vitess (MySQL), Citus (Postgres); cross-shard queries become app-level fan-out
- Distributed-native: Cassandra, DynamoDB, Spanner, CockroachDB — horizontal out of the box
- NewSQL: Spanner, CockroachDB, TiDB — SQL semantics with horizontal scaling
Recommendation
Diagonal scaling is the real-world default. Start vertical because it's cheap and zero-effort; push to horizontal once you hit hardware ceilings, single-failure cost is unacceptable, or per-instance cost climbs superlinearly. Stateless services scale out trivially via load balancer + autoscaling — push state down to Redis or the database. Keep relational databases vertical with read replicas for as long as possible; shard only when write throughput truly demands it. For new systems with global scale needs, consider distributed-native (Cassandra) or NewSQL (Spanner/CockroachDB) from day one to avoid a painful sharding migration later.
Horizontal vs Vertical Scaling: When to Scale Out vs Scale Up
Direct Answer
Vertical (scale up) — buy a bigger machine. Simple, no code changes, but bounded by the largest available instance and a single point of failure. Horizontal (scale out) — add more machines behind a load balancer. Effectively unbounded, fault-tolerant, but requires the workload to be stateless or shardable. The pragmatic order: scale up first (it's cheap and zero-effort) until you hit a wall — hardware ceiling, single-instance unavailability cost, or per-instance cost climbing faster than throughput. Then scale out, which is where modern cloud-native systems live. Stateless services scale out trivially; stateful systems (databases) need sharding or specialized architectures.
Common Mistakes & Pitfalls
Treating one as universally better, or assuming horizontal scaling is free (it requires architectural design — statelessness, sharding, distributed coordination).
Check your understanding
Answer these without looking back at the article.
- Walk through the migration path from a vertically-scaled Postgres to a sharded Postgres setup with Citus or Vitess.
- What's the cost analysis for one 64xlarge vs eight 8xlarges for a stateless API? When does each win?
- How does autoscaling react to a 10x traffic spike in 30 seconds? What pre-provisioning do you need?
- Design the scaling strategy for a real-time leaderboard service — vertical Redis or sharded?
Related interview prep categories
2Want a guided curriculum order?
These modules are also sequenced in our flagship backend interview track — open it when you prefer an ordered path instead of browsing by topic.