Scalability: Vertical vs Horizontal
Scalability is the property of a system to handle a growing amount of work by adding resources to the system. In system design, we generally talk about two primary ways to scale: Vertical Scaling (Scaling Up) and Horizontal Scaling (Scaling Out).
Vertical Scaling (Scaling Up)
Vertical scaling means adding more power (CPU, RAM, Disk) to an existing machine.
- Pros: Simple to implement (no code changes), lower network latency (all components on one box), easier to manage.
- Cons: Has a hard upper limit (you can only buy so much RAM), single point of failure (if the machine dies, everything dies), expensive (high-end hardware is pricey).
Horizontal Scaling (Scaling Out)
Horizontal scaling means adding more machines to your pool of resources.
- Pros: Practically limitless (just add more servers), high availability (if one node fails, others continue), cost-effective (use commodity hardware).
- Cons: Increases complexity (requires load balancers, service discovery), data consistency issues, network latency between nodes.
| Feature | Vertical Scaling | Horizontal Scaling |
|---|---|---|
| Method | Add resources to one machine | Add more machines |
| Simplicity | High | Low |
| Availability | Low (Single node) | High (Multi-node) |
| Max Capacity | Hardware limits | Theoretically infinite |
| Cost | Non-linear (Expensive hardware) | Linear (Commodity hardware) |
Elasticity vs Scalability
While often used interchangeably, they are different:
- Scalability: The capacity to handle more load.
- Elasticity: The ability to automatically scale up or down based on current demand (common in cloud environments).
Knowledge Check
Question 1 of 3
Q1Single choice
Which scaling method involves adding more RAM and CPU to a single server?