SCALABILITY & PERFORMANCE / SYSTEM CONCEPT BRIEF

Vertical vs horizontal scaling

Vertical scaling (scaling up) means giving one machine more resources: more CPU, memory, or faster disks.

BeginnerPhase 03 / Topic 1 of 13RequirementsTrade-offsFailure modes
01

Overview

Vertical scaling (scaling up) means giving one machine more resources: more CPU, memory, or faster disks. Horizontal scaling (scaling out) means adding more machines and spreading the work across them. Vertical scaling is simple but hits a hardware ceiling and keeps a single point of failure; horizontal scaling is nearly unlimited and improves availability but requires the software to be designed for distribution.

Most real systems use both: scale vertically until it is expensive or risky, then scale horizontally. Stateless tiers (web and API servers) scale out easily behind a load balancer; stateful tiers (databases) are harder and need replication or sharding.

A busier restaurant

Vertical scaling is hiring a faster chef and buying a bigger stove; eventually no chef is fast enough. Horizontal scaling is opening more kitchens with the same recipes; you need a host to route orders and a way to share ingredients.

02

When to use it

  • Vertical: early-stage products, databases that are hard to split, quick relief.
  • Horizontal: traffic beyond one machine, high availability, elastic demand.
  • Horizontal for stateless services; carefully planned for stateful ones.
  • Cost optimization: many small instances vs one large instance.
03

Where it shows up in interviews

Scaling a web tier

Recognize it when: traffic grows 10-100x.

  • Scale a single-server app to millions of users
  • Design Instagram's backend
Scaling the data tier

Recognize it when: the database is the bottleneck.

  • Design Twitter's storage
  • Scale a relational database beyond one node
04

Where it is used in real software

Stack Overflow

Famously served huge traffic from a small number of powerful SQL Server machines, showing how far vertical scaling can go.

Cloud auto scaling groups

AWS Auto Scaling, GCP managed instance groups, and Kubernetes HPA add or remove instances automatically based on load.

Managed databases

Amazon RDS lets you change instance size (vertical) and add read replicas (horizontal reads).

05

Key terms

Scale up
Bigger machine.
Scale out
More machines.
Stateless service
Any instance can serve any request because state lives elsewhere.
Elasticity
Adding and removing capacity automatically with demand.
Single point of failure
A component whose failure takes the whole system down.
06

How it works, step by step

  1. 1
    Measure the bottleneck

    CPU, memory, disk I/O, network, or the database?

  2. 2
    Scale up for quick relief

    Resize the instance; often minutes of downtime or a failover.

  3. 3
    Make the tier stateless

    Move sessions and files to Redis and object storage.

  4. 4
    Scale out behind a load balancer

    Add identical instances; enable auto scaling.

  5. 5
    Scale the data tier

    Caching, read replicas, then partitioning or sharding.

07

Vertical vs horizontal

Key differences

Step 1 / 5
AspectVerticalHorizontal
LimitLargest available machinePractically unlimited
ComplexityLow (no code changes)Higher (distribution, state)
AvailabilitySingle point of failureSurvives instance failures
Cost curveGrows faster than linearly at the top endRoughly linear
Downtime to scaleOften a restartNone (add instances)

NOWAspect: Limit | Vertical: Largest available machine | Horizontal: Practically unlimited

Start simple, but design stateless services from day one so scaling out later is a configuration change, not a rewrite.

08

Implementation

apiVersion: autoscaling/v2kind: HorizontalPodAutoscalermetadata:  name: apispec:  scaleTargetRef:    apiVersion: apps/v1    kind: Deployment    name: api  minReplicas: 3          # at least one per availability zone  maxReplicas: 50  metrics:    - type: Resource      resource:        name: cpu        target: { type: Utilization, averageUtilization: 65 }
09

Complexity and performance

Largest cloud VMshundreds of vCPUs, TBs of RAM

Vertical ceiling is high but finite.

Scale-out timeseconds to minutes

Containers vs VMs.

10

Trade-offs

Simplicity vs resilience

One big server is easier to run and debug but is a single point of failure.

Coordination cost

Horizontal systems need load balancing, shared state, and handling of partial failures.

11

Variants and related techniques

Diagonal scaling

Scale up to a sweet spot, then scale out with that instance size.

Functional partitioning

Split the system by feature into separately scaled services.

12

Common mistakes

  • Local state in app servers.

    Fix: Externalize sessions, uploads, and caches before scaling out.

  • Scaling the wrong tier.

    Fix: Adding web servers does not help if the database is saturated.

13

Interview questions

How would you scale a single-server web app to millions of users?

Separate the database, put stateless app servers behind a load balancer with auto scaling, add a cache and CDN, add read replicas, move slow work to queues, and eventually shard the data.

Why is horizontal scaling harder for databases than for web servers?

Databases hold state. Spreading writes across machines requires partitioning data and handling consistency and cross-shard queries, while web servers can simply be cloned.

14

Practice problems

ProblemDifficultyWhat it trains
Scale from 1 to 1M users step by stepMediumTier-by-tier evolution.
Decide scale-up vs scale-out for a reporting databaseMediumTrade-offs.