Vertical vs Horizontal Scaling
Overview
Scalability means a system keeps working well as demand grows. There are two basic ways to get more capacity: make one machine bigger, or add more machines. Almost every large system uses a mix of both.
Detailed Notes
What is scalability
Scalability is the ability to handle more load by adding resources, without redesigning the whole system. Load is whatever demand you measure: requests per second, concurrent users, data size. Capacity is the most load the system can take while still meeting its targets.
Scalable is not the same as fast. A fast system answers one request quickly (see the latency chapter). A scalable system keeps answering quickly as requests multiply.
The problem it solves
A ticket-booking site runs on one server with 8 CPU cores and 32 GB of memory. On a normal day it is fine. When a popular concert goes on sale, 50,000 people arrive at once. CPU hits 100%, pages time out, and people refresh, which makes it worse. The team needs more capacity, and has two options.
How it works
Vertical scaling (scale up) means making one machine more powerful: more CPU, more memory, faster disk.
- Simplest option: no code changes and no coordination between machines.
- Example: moving a database from 16 GB to 256 GB of memory.
- Limits: there is a biggest machine you can buy, prices climb steeply near the top, you usually need a restart, and one machine is still a single point of failure (if it dies, everything stops).
Horizontal scaling (scale out) means adding more machines that share the work.
- Almost no ceiling, and if one machine dies, only a small share of capacity is lost.
- Example: going from 2 to 20 identical web servers.
- Limits: you need something to split traffic between the machines (a load balancer, covered later), and the application must be designed so any machine can serve any request. That design is the next lesson.
| Aspect | Vertical (scale up) | Horizontal (scale out) |
|---|---|---|
| What changes | The machine gets bigger | The number of machines grows |
| Code changes | Usually none | Often needed |
| Upper limit | Biggest machine available | Very high |
| If one fails | Everything on it is lost | A small share is lost |
| Downtime to scale | Often a restart | Usually none |
| Complexity | Low | Higher |
How a team decides: find the current bottleneck (CPU, memory, disk, network). If a bigger machine removes it cheaply, scale up first. If you are near the largest sensible machine, or need to survive machine failures, scale out. Then measure again; the bottleneck usually moves.
A simple example
A restaurant that is too busy can hire one superhuman chef who cooks faster (scale up), or hire more ordinary cooks and open more stations (scale out). The superchef is simple to manage, but there is a limit to how fast one person works, and if they get sick the kitchen stops. More cooks need a head chef to split the orders, but you can keep adding them and one absence barely matters.
System design example
A shop starts on one server and one database. Early on, scaling up is the right, cheap move. Later, the web servers are cloned and traffic is split between them (scale out), while the database, which is harder to spread across machines, is scaled up first and spread out later. Techniques for spreading data (copies of the database, caching, splitting data) are covered in later chapters.
Summary
- Scalability = handling more load by adding resources.
- Scale up = bigger machine: simple, but has a ceiling and a single point of failure.
- Scale out = more machines: huge headroom and resilience, but more complexity.
- Start simple; scale out when you hit limits or need fault tolerance.
Architecture Diagram
One bigger machine versus many equal machines sharing the work.
- 1Scale up: make the one server stronger.
- 2Scale out: add more servers.
- 3A load balancer (covered later) spreads requests across them.
Common Interview Questions
Finished this lesson?
0 of 91 lessons done · 0% of the course

