Courses 0%
38
Foundations of System Design · Chapter 38 of 42

Vertical and Horizontal Scaling

Akhil
Akhil Sharma
20 min

Horizontal vs Vertical Scaling - The Growth Strategy

🎯 Challenge The Pizza Restaurant Dilemma

Scenario: Your pizza restaurant is packed every night. There's a 2-hour wait!

You have two options to handle more customers:

Option A: Hire a superhuman chef who can make pizzas 10x faster (but costs 10x more)

Option B: Hire 10 regular chefs, each working at normal speed

Think about it: Which would you choose and why?


🍕 The Scaling Revelation

This is exactly the difference between Vertical and Horizontal Scaling!

🏢 VERTICAL SCALING (Option A) ═══════════════════════════════════ Make your single server MORE POWERFUL

img1
Like: Upgrading your laptop to a supercomputer

🏗️ HORIZONTAL SCALING (Option B) ═══════════════════════════════════ Add MORE servers (keep each one normal)

img2

Like: Building a team instead of finding a superhero


🎮 Interactive Comparison: The Office Analogy

Scenario: Your company needs to handle more customer support tickets.

Vertical Scaling Approach:

img3

Horizontal Scaling Approach:

img4


📊 Real-World Scaling Example: Web Server Overload

Problem: Your website gets 1,000 requests/second, but your server can only handle 500 req/sec.

Visual representation:

❌ BEFORE (Overloaded):

img5
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✅ VERTICAL SCALING SOLUTION:

img6

Pros: Simple - just upgrade one server Cons: Expensive, has limits, single point of failure

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✅ HORIZONTAL SCALING SOLUTION:

img7

Total capacity: 2000 req/sec! 😊 💰 Cost: 4 cheap servers < 1 mega server Bonus: If one fails, others continue!

Pros: Cost-effective, redundant, unlimited growth Cons: More complex architecture


🚨 Common Misconception: "Vertical Scaling is Always Bad"

You might think: "Horizontal scaling sounds way better. Why would anyone use vertical scaling?"

The Truth: Both have their place!

✅ WHEN TO USE VERTICAL SCALING ════════════════════════════════════

Good for: • Databases (hard to split data across servers) • Applications that need shared memory • Legacy software that can't be distributed • Small to medium traffic • When simplicity matters

Example: Your PostgreSQL database You CAN'T easily split it across 10 servers (complex!) Easier to give it more RAM and CPU

img8

✅ WHEN TO USE HORIZONTAL SCALING ════════════════════════════════════

Good for: • Stateless web servers • Microservices • High traffic applications • When you need redundancy • Unlimited growth potential

Example: Your web application Easy to run same code on 100 servers!

img9

Real-world parallel:

  • Vertical: Like buying a bigger house when you need more space
  • Horizontal: Like building an apartment complex with many units

🎯 Decision Game: Scale Up or Scale Out?

For each scenario, choose Vertical or Horizontal scaling:

Scenario A: Netflix streaming servers serving video to millions Scenario B: Main MySQL database storing user accounts Scenario C: Image processing API that resizes photos Scenario D: Redis cache for session storage Scenario E: E-commerce website frontend

Think about each one...


ANSWERS:

Scenario A: HORIZONTAL ✓ Why: Stateless video servers, millions of users Solution: 1000s of servers in data centers worldwide

Scenario B: VERTICAL ✓ Why: Database needs consistency, complex to split Solution: Upgrade to high-memory server

Scenario C: HORIZONTAL ✓ Why: Each image processed independently Solution: 50 servers processing in parallel

Scenario D: BOTH! Why: Vertical to start, then horizontal with clustering Solution: Upgrade RAM first, then add cache nodes

Scenario E: HORIZONTAL ✓ Why: Stateless web servers, easy to duplicate Solution: 20+ identical web servers behind load balancer


📈 The Scaling Progression: How Real Companies Grow

Watch a typical startup's scaling journey:

👶 STAGE 1: TINY STARTUP (0-1K users) ═════════════════════════════════════

img10

Strategy: Nothing! One server is fine.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📈 STAGE 2: GROWING (1K-10K users)

═════════════════════════════════════

img11

Strategy: VERTICAL scaling of database

Cost: $500/month

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🚀 STAGE 3: POPULAR (10K-100K users)

═════════════════════════════════════

img2

Strategy: HORIZONTAL apps + VERTICAL database

Cost: $5,000/month

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🌟 STAGE 4: MASSIVE (100K+ users)

═════════════════════════════════════

img13

Strategy: BOTH everywhere!

Cost: $50,000/month

Companies: Netflix, Facebook, Twitter at this stage


💰 Cost Comparison: The Reality Check

Example: Handling 10,000 requests/second

💸 VERTICAL SCALING COSTS

═════════════════════════════════

Single mega-server:

• 64 CPUs

• 512 GB RAM

• 10 TB SSD

Cloud cost: $5,000/month

Problems:

❌ Single point of failure

❌ Expensive

❌ Can't grow beyond physical limits

❌ Maintenance downtime affects everyone

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

💸 HORIZONTAL SCALING COSTS

═════════════════════════════════

10 medium servers:

• 8 CPUs each

• 64 GB RAM each

• 1 TB SSD each

Cloud cost: $3,000/month (cheaper!)

Benefits:

✅ One fails? 9 others continue

✅ Cost effective

✅ Can add more easily

✅ Update one at a time (no downtime)

Winner: Horizontal! 🎉


🎪 The Ultimate Comparison Table

img14

Key Insight: Start vertical, grow horizontal!


🔑 The Hybrid Approach: Best of Both Worlds

Real-world wisdom: Most large systems use BOTH!

Modern Architecture:

═══════════════════

img15

Strategy:

• Scale web/app servers horizontally (easy!)

• Scale database vertically first (simpler)

• Add database read replicas horizontally later

• Use caching layer (horizontal) to reduce DB load


Key Takeaways

  1. Vertical scaling (scale up) means adding more resources to a single machine — simpler but has a hardware ceiling
  2. Horizontal scaling (scale out) means adding more machines — more complex but virtually unlimited capacity
  3. Stateless services are easy to scale horizontally — move session state to an external store (Redis, database)
  4. Most production systems use both — scale up first for simplicity, scale out when you hit the ceiling
  5. Auto-scaling adjusts capacity based on demand — use metrics like CPU, memory, or request queue depth as triggers
LOG IN

Log in to keep reading

Create a free account to keep reading and track your progress.

Log in — it's free
Chapter complete!

Course Complete!

You've finished all 42 chapters of

Introduction to System Design

Browse courses
Up next Load Balancing
Continue
preview