| Users/Traffic | Vertical Scaling | Horizontal Scaling |
|---|---|---|
| 100 users | Single server with moderate CPU/RAM handles load easily | Single server; no need for multiple servers |
| 10,000 users | Upgrade server CPU, RAM, and storage to handle more load | Add a few servers behind a load balancer to share traffic |
| 1,000,000 users | Server hardware limits reached; expensive and risky upgrades | Many servers distributed; load balancer and data partitioning needed |
| 100,000,000 users | Vertical scaling impractical; single server cannot handle load | Large cluster of servers; complex orchestration and sharding required |
Vertical scaling vs horizontal scaling in HLD - Scaling Approaches Compared
With vertical scaling, the first bottleneck is the physical limits of a single server's CPU, memory, and storage capacity. Once maxed out, no further upgrades are possible without downtime or huge cost.
With horizontal scaling, the first bottleneck is often the coordination layer, such as load balancers or database consistency, which can become complex as servers increase.
- Vertical Scaling: Upgrade server hardware (CPU, RAM, SSD). Simple but limited by max hardware specs and cost.
- Horizontal Scaling: Add more servers to distribute load. Requires load balancers, data partitioning (sharding), and stateless design.
- Caching: Use caches (like Redis) to reduce load on servers and databases in both scaling types.
- Database Scaling: Vertical scaling by bigger DB server; horizontal scaling by read replicas and sharding.
- Network: Use CDNs to offload static content and reduce server load in horizontal scaling.
Assuming 1,000 requests per second (RPS) per server:
- Vertical scaling: Upgrading server to handle 5,000 RPS costs 3x more hardware but limited by max specs.
- Horizontal scaling: 5 servers at 1,000 RPS each; cost scales linearly but adds complexity.
- Storage: Vertical scaling requires bigger disks; horizontal scaling distributes data across servers.
- Bandwidth: 1 Gbps network supports ~125 MB/s; multiple servers share bandwidth load.
Start by explaining vertical scaling as upgrading a single machine's resources. Then contrast with horizontal scaling by adding more machines. Discuss pros and cons, bottlenecks, and when to choose each. Use simple examples like upgrading a car engine vs buying more cars to share the load.
Your database handles 1,000 QPS. Traffic grows 10x to 10,000 QPS. What do you do first?
Answer: Add read replicas to distribute read queries and reduce load on the primary database before considering vertical upgrades or sharding.
Practice
Solution
Step 1: Understand vertical scaling definition
Vertical scaling means improving one machine's capacity by adding resources like CPU, RAM, or storage.Step 2: Compare with other options
Options B and C describe horizontal scaling or data partitioning, and D is about caching, not scaling.Final Answer:
Adding more resources like CPU or RAM to a single machine -> Option DQuick Check:
Vertical scaling = adding resources to one machine [OK]
- Confusing vertical scaling with horizontal scaling
- Thinking adding machines is vertical scaling
- Mixing caching with scaling
Solution
Step 1: Identify horizontal scaling characteristics
Horizontal scaling means adding more machines to share the workload, often managed by a load balancer.Step 2: Eliminate other options
Options B and C describe vertical scaling (upgrading one machine), and D is about network hardware, not scaling.Final Answer:
Adding multiple servers behind a load balancer -> Option AQuick Check:
Horizontal scaling = add machines behind load balancer [OK]
- Choosing upgrading one server as horizontal scaling
- Confusing network upgrades with scaling
- Ignoring load balancer role
Solution
Step 1: Analyze capacity needs for doubled traffic
Doubling traffic usually requires doubling processing power or distributing load.Step 2: Compare vertical vs horizontal scaling efficiency
Vertical scaling (Upgrade the server to 16 CPU cores and 32GB RAM (vertical scaling)) can be costly and limited by hardware max. Horizontal scaling (Add one more identical server and use a load balancer (horizontal scaling)) adds another server to share load, often more efficient and scalable.Final Answer:
Add one more identical server and use a load balancer (horizontal scaling) -> Option BQuick Check:
Doubling capacity = add server (horizontal) better than upgrade [OK]
- Assuming vertical scaling always doubles capacity easily
- Ignoring load balancer role in horizontal scaling
- Confusing storage increase with processing capacity
Solution
Step 1: Understand vertical scaling limits
Vertical scaling improves one machine but has physical hardware limits beyond which it cannot handle more load.Step 2: Analyze crash cause
Since the server crashes under load after upgrades, it likely hit max capacity. Other options relate to load balancer, storage, or network, which are less likely causes here.Final Answer:
The server reached hardware limits and cannot scale further vertically -> Option AQuick Check:
Vertical scaling hits hardware limits causing crashes [OK]
- Blaming load balancer when none is used
- Confusing storage issues with CPU/RAM limits
- Ignoring hardware capacity limits
Solution
Step 1: Identify startup needs
Rapid growth and unpredictable spikes require flexible, scalable solutions that can adjust resources quickly without downtime.Step 2: Evaluate scaling options for flexibility and cost
Vertical scaling (Vertical scaling by upgrading a powerful single server) is limited and costly for spikes. Manual upgrades (Relying on manual server upgrades during peak times) cause downtime and delay. Single server (Using a single server with a large database) risks failure. Horizontal scaling with auto-scaling (Horizontal scaling with multiple servers and auto-scaling) adds/removes servers dynamically, balancing cost and uptime.Final Answer:
Horizontal scaling with multiple servers and auto-scaling -> Option CQuick Check:
Rapid growth needs horizontal auto-scaling for cost and uptime [OK]
- Choosing vertical scaling for unpredictable spikes
- Ignoring downtime caused by manual upgrades
- Relying on single server risking failure
Ready to prove it?
Pass the test and this pattern moves unknown
