Back to blog

Bigger server or more servers: which fix buys you time?

Thắng Đoàn
Thắng Đoàn

FotoFlow has 2,000 users and a viral photo post just multiplied traffic overnight. The single server that laughed at 100 users now shows CPU near 100 percent, a growing request queue, rising latency, and the first timeouts: the textbook picture of overload.

Way 1: buy a bigger machine

The simplest fix is moving to a bigger box: more cores, more memory, faster disks. The code does not change or even notice. This is vertical scaling, and it is a great first move. Four times the machine is roughly four times the price, and there is nothing new to operate.

But it has a hard ceiling. Machines only get so big, and software rarely uses 192 cores as well as it used 16: locks, shared memory, and one disk get in the way. Every upgrade is also a migration with a restart and downtime. A server has a fixed budget of CPU, memory, disk, and network; capacity is how many requests per second it serves before one of those runs out.

The problem a bigger box cannot fix

Worse: everything depends on that one machine. A bad deploy, a full disk, or a dead power supply and FotoFlow is offline for everyone. A component whose failure takes the whole system down is a single point of failure. However big it is, one box is always one failure away from a full outage.

Way 2: run several smaller machines

Instead of one giant server, run several mid-size ones side by side, all running the same code. Need more capacity? Add another server. This is horizontal scaling, and it is how virtually every large system grows. Mid-size machines are the best value, there is no hard ceiling, and four 96-core servers have about twice the capacity of the biggest single machine, while any one of them can fail and the rest carry the load.

Traffic follows the clock, so follow traffic back

At 8 p.m. FotoFlow needs every server; at 4 a.m. traffic is a tenth of that and the machines idle at 5 percent CPU. Consumer apps commonly swing 3 to 10 times between their daily peak and their nightly trough. Because scaled-out servers are interchangeable, an autoscaler can add and remove them automatically, keeping average CPU near 50 percent, scaling in at night but never below two machines so one can still fail. You pay roughly for what you use.

The catch: a new server takes about three minutes to boot and warm up. A flash sale that multiplies traffic five times in two minutes outruns the autoscaler, and for those minutes the running servers serve only two thirds of the load. Autoscaling reacts; it cannot predict. Pre-warm for launches, sales, and big broadcasts.

What this does not solve

Scaling out creates two new problems this post does not answer: users still know only one server address, so who steers requests to healthy machines? And if Alice's login session lives in Server A's memory, what happens when her next request lands on Server B? Both are the next two posts.

If your app fell over tomorrow, would the fix be more CPU, or one more copy of the same box?
What is the biggest spike your traffic sees in a normal week, and would three minutes of scaling lag survive it?

Scale up while it is cheap and simple, then scale out.

Next in the series: Three servers, one IP: who gets the next request?

Sources

System Design Primer

Designing Data-Intensive Applications

undefined

Google SRE Books

Share:

Recommended for you

Enjoyed this article?

Subscribe for new articles. No spam. Unsubscribe anytime.

No pasting. This is the challenge.0/200

Typed live, never pasted.