Scalability Basics (Vertical vs Horizontal)
Learn how vertical and horizontal scaling work, when to use each, and how they impact real-world system performance.
Why It Matters
Your system will not stay small.
Traffic grows. Data grows. Users increase.
If your system cannot handle growth, it crashes or slows down.
This is where scalability comes in.
Every real system needs a scaling strategy.
You will face this in:
- system design interviews
- building production apps
- scaling side projects
What This Concept Actually Means
Scalability is the ability of a system to handle increased load.
There are two main ways to scale:
Vertical Scaling (Scale Up)
Increase power of a single machine.
Example:
- Upgrade server from 4 CPU, 8GB RAM
- To 16 CPU, 64GB RAM
Horizontal Scaling (Scale Out)
Add more machines to handle load.
Example:
- 1 server handling 1,000 requests per second
- 10 servers handling around 10,000 requests per second
Think like this:
- Vertical = stronger machine
- Horizontal = more machines
How It Works
Let’s take an e-commerce API.
Initial System
- 1 server
- Handles 1,000 requests per second
Problem
Traffic increases to 5,000 requests per second
Option 1: Vertical Scaling
- Upgrade server capacity
- New capacity: 4,000 requests per second
Still not enough.
Option 2: Horizontal Scaling
- Add 5 servers
- Each handles 1,000 requests per second
- Total capacity: around 5,000 requests per second
Now system can handle traffic.
Flow:
Diagramflowchart LR User --> LoadBalancer LoadBalancer --> Server1 LoadBalancer --> Server2 LoadBalancer --> Server3 Server1 --> Database Server2 --> Database Server3 --> Databasevisualized by
Key Techniques / Variations
1. Load Balancing
Distribute traffic across servers.
- Round robin
- Least connections
2. Auto Scaling
Automatically add or remove servers based on load.
Example:
- CPU usage above 70 percent adds new server
3. Stateless Services
Make servers independent.
Benefit:
- easy horizontal scaling
4. Database Scaling
- Read replicas for scaling reads
- Sharding for scaling writes
Trade-offs and Design Decisions
When to use vertical scaling
- early stage systems
- low traffic apps
When to use horizontal scaling
- high traffic systems
- global applications
Pros of vertical scaling
- simple to implement
- no major architecture changes
Cons of vertical scaling
- hardware limits
- expensive upgrades
- single point of failure
Example:
- Server upgrade cost: 10k per month to 30k per month for higher CPU and RAM
- Still limited to one machine
Pros of horizontal scaling
- high scalability
- fault tolerance
- gradual cost increase
Cons of horizontal scaling
- complex architecture
- requires load balancing
Example:
- 1 server cost: 10k per month
- 3 servers: 30k per month
- Can scale gradually as traffic grows instead of large upfront upgrade
Architecture / Flow Diagram
Diagramflowchart LR Client --> LoadBalancer LoadBalancer --> AppServer1 LoadBalancer --> AppServer2 AppServer1 --> Database AppServer2 --> Databasevisualized by
Failure Modes To Watch
- single server crash in vertical scaling
- uneven load distribution
- database bottleneck
- stateful servers blocking scaling
Design Checklist
Ask yourself:
- What is current load? (e.g., 1,000 RPS)
- What is expected growth? (e.g., 10,000 RPS)
- Can my system scale horizontally?
- Is my service stateless?
- Where is the bottleneck?
Summary
- Scalability is handling growth in traffic and data
- Vertical scaling means increasing machine power
- Horizontal scaling means adding more machines
- Horizontal scaling is preferred for large systems
- Real systems often use a combination of both
Which scaling approach is better?
Horizontal scaling is generally preferred for large systems, but vertical scaling is simpler and useful at early stages.
Can we use both vertical and horizontal scaling?
Yes. Many production systems combine both approaches for optimal performance.