Module 4 — Scaling

Vertical vs Horizontal Scaling

Two fundamental approaches to handling more load. Know when to use each.

1The Building Analogy

💡 Simple Analogy
Vertical Scaling (Scale Up): Make your building taller—add more floors to handle more people.

Horizontal Scaling (Scale Out): Build more buildings across the city—spread people across multiple locations.

Eventually, you can't make a building infinitely tall (hardware limits). But you can always build more buildings (add servers).

2Visual Comparison

Vertical (Scale Up)

+RAM
+CPU
Server

One bigger, more powerful machine

Horizontal (Scale Out)

S1
S2
S3
S4

Many smaller machines working together

3Detailed Comparison

AspectVerticalHorizontal
HowAdd CPU, RAM, storageAdd more servers
LimitHardware maximumTheoretically unlimited
CostExponential (high-end expensive)Linear (commodity hardware)
DowntimeUsually requiredCan add without downtime
ComplexitySimple (one machine)Complex (distributed system)
Fault ToleranceSingle point of failureRedundancy built-in

4When to Use Each

Use Vertical When

  • • Early stage, simple architecture needed
  • • Database servers (hard to distribute)
  • • Application requires lots of memory
  • • Quick fix while planning horizontal
  • • Costs are not primary concern

Use Horizontal When

  • • Stateless application servers
  • • Need fault tolerance / redundancy
  • • Scale beyond single machine limits
  • • Variable load (scale up/down)
  • • Cost efficiency at scale

5Horizontal Scaling Requirements

Horizontal scaling requires your application to be designed for distribution:

Stateless Services: No local state—any server can handle any request. Store state externally (Redis, DB).
Load Balancer: Distribute requests across servers. Handle server failures gracefully.
Shared Storage: All servers access same data. Database, object storage, distributed cache.
Session Management: Sessions stored externally (Redis) not in server memory.

6Key Takeaways

1Vertical scaling = bigger machine. Simple but has limits.
2Horizontal scaling = more machines. Complex but unlimited.
3Start vertical (simpler), then go horizontal when needed.
4Horizontal requires stateless design and external state storage.
5Most modern web apps use horizontal for app servers, vertical for databases.
6In interviews: discuss trade-offs, not just "horizontal is better."