What is Scalability?
Scalability is the property of a system to handle a growing amount of work by adding resources to the system.
1. Vertical Scaling (Scale Up)
Adding more power (CPU, RAM, SSD) to an existing server.
- Pros: Simple, no code changes needed, high performance for a single task.
- Cons: Has a hard "Vertical Ceiling," single point of failure (SPOF), and downtime during upgrades.
- Real-world Analogy: Buying a bigger truck to carry more boxes.
2. Horizontal Scaling (Scale Out)
Adding more servers to the resource pool.
- Pros: No theoretical limit to growth, higher availability (redundancy), and zero-downtime scaling.
- Cons: High architectural complexity, requires a Load Balancer, and application must be Stateless.
- Real-world Analogy: Hiring 10 more trucks to carry the load.
3. The Stateless Requirement
To scale horizontally, your application servers must be stateless. This means any server can handle any request.
- State: User sessions, local temporary files.
- Fix: Move state to a shared database or distributed cache (Redis).
4. Trade-offs Summary
| Feature | Vertical | Horizontal |
|---|---|---|
| Complexity | Low | High |
| Availability | SPOF | Redundant |
| Limit | Hard Ceiling | Infinite |
| Cost | Non-linear (expensive) | Linear (cheaper) |
Final Takeaway
Always start with Vertical scaling if you can, but design for Horizontal scaling from day one.