CONCEPT SHEET · Concepts

Scaling: Horizontal vs Vertical

One-liner: Vertical scaling buys a bigger box; horizontal adds boxes, which requires stateless services and shared-nothing design.

ArticleConcepts© Arthur Bernier Jr579 words1 code block

Say this#

How it works#

TEXT
Scale cube:  X-axis: [app][app][app] behind LB            (clone)  Y-axis: [users svc] [orders svc] [search svc] (functional split)  Z-axis: [shard 0] [shard 1] [shard 2]         (data split by key)
  1. Start vertical: bigger instance, tune, add indexes; cheapest engineering.
  2. Make app tier stateless: sessions to Redis, uploads to S3, local caches tolerated as best-effort.
  3. Put instances behind an LB; auto-scale on a leading indicator (requests per target, queue depth) not just CPU.
  4. Scale reads with cache + replicas; scale writes with sharding (Z-axis) only when forced.
  5. Pre-warm before predictable spikes; set min instances to avoid cold-start cliffs.

Trade-offs#

ChoiceProCon
VerticalZero architecture change, strong consistency stays simpleCeiling, cost grows superlinearly, SPOF, downtime to resize
HorizontalNo ceiling in principle, fault tolerance, elasticNeeds statelessness, LB, distributed coordination, data layer becomes bottleneck
Sessions in RedisAny node serves any userRedis is a dependency; extra hop
Sessions in JWT cookieNo server stateRevocation hard; size on every request
Auto-scaling on CPUSimpleLags behind IO-bound or queue-driven load
ServerlessScale-to-zero, no fleet opsCold starts, runtime limits, cost at steady high load

Numbers#

  • Largest cloud VMs today: hundreds of vCPUs and tens of TB RAM (e.g. AWS u-series up to 24-32 TB); vertical goes far for databases.
  • Stateless app tier: a modest node serves roughly thousands of req/s for simple endpoints; scale count = peak QPS / per-node capacity / 0.7 headroom, plus 1.
  • Auto-scaling reaction time: ~1-5 min for VMs, seconds for containers; design buffers (queues) for that gap.
  • Lambda cold start: ~100 ms to a few seconds depending on runtime and package size.

In the interview#

See also