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).
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).
2Comparison
| Aspect | Vertical | Horizontal |
|---|---|---|
| Approach | Bigger machine | More machines |
| Cost | Exponential | Linear |
| Limit | Hardware ceiling | Theoretically unlimited |
| Downtime | Required for upgrade | Zero downtime |
| Complexity | Simple | Distributed systems |
3Vertical Scaling
Vertical scaling means upgrading your existing machine: more CPU, RAM, faster storage.
Pros
- ✓Simple-no code changes
- ✓No distributed complexity
- ✓Good for databases
Cons
- ✗Hardware limits
- ✗Single point of failure
- ✗Expensive at scale
4Horizontal Scaling
Horizontal scaling means adding more machines and distributing load across them.
Pros
- ✓No hardware ceiling
- ✓Fault tolerant
- ✓Cost-effective at scale
Cons
- ✗Distributed complexity
- ✗Data consistency challenges
- ✗Requires load balancing
5When to Use Each
Use Vertical
- • Early-stage startups
- • Database servers (initially)
- • Quick fix for immediate load
- • Simple stateful apps
Use Horizontal
- • High-traffic web apps
- • Stateless services
- • Need for high availability
- • Long-term scaling strategy
6Key Takeaways
1Vertical = bigger machine, Horizontal = more machines
2Vertical is simpler but has hardware limits
3Horizontal enables unlimited scaling but adds complexity
4Most systems use both-scale up then scale out
5Stateless services are easier to scale horizontally
?Quiz
1. Your single server is at 90% CPU. Quick fix?
2. Web app needs to handle 10x traffic long-term. Best approach?