LESSON 03 · Capacity and failover

Grow the web tier

Know when to strengthen one machine and when to add more.

SYSTEM VIEW

The architecture

Diagram view
Peak load—
Healthy servers—
Per server—

Watch one server get bigger, then get help, then lose a machine.

  1. Every visitor reaches the same web server. At modest load, that’s simple.

    What changed

    • One web server
  2. Vertical scaling adds CPU or memory to one server, with no code changes. But hardware has limits, the upgrade often means a restart, and the one server can still fail. For a small internal tool, that may still be the better trade.

    What changed

    • More CPU and memory
    • A restart to upgrade
    • Still one server to fail
  3. As the peak grows to 900 requests a second, horizontal scaling adds servers of the same size to a pool instead of growing one machine. A load balancer takes public traffic and routes each request to a healthy server, usually on a private address. If each handles 300 requests a second, three are exactly enough.

    What changed

    • Peak grows to 900 req/s
    • Load balancer, Web B and Web C
    • Web A, standard size like B and C
  4. Web C dies. The balancer requests /healthz every 5 seconds and drops a server after two failures, so C still gets requests for about 10 seconds and clients need sensible retries.

    What changed

    • Web C fails two checks
    • About 10 s of requests still sent to C
  5. A and B now take the whole 900 peak: 450 requests a second each, past the 300 each can handle. The balancer won’t start a replacement; it only routes to the servers it has.

    What changed

    • A and B at 450 req/s, past 300
    • The balancer doesn’t replace C
  6. With C back and D registered, four servers run at 225 each and rise to 300 after a failure. The balancer needs redundancy too.

    What changed

    • Web D, registered
    • 225 req/s each, 300 after a loss
    Servers lost

Space plays · ← → step · Home resets

THE IDEA

How it works

Vertical scaling adds CPU or memory to one server. It is simple at modest load and needs no code changes, but hardware has limits, upgrades often mean a restart, and that server can still fail. Horizontal scaling adds servers to a pool, giving more capacity and allowing traffic to continue when one instance is unavailable.

A load balancer receives public traffic and routes requests to healthy web servers, usually reached over private network addresses that are not exposed to the internet. It finds healthy servers with health checks: it requests a path such as /healthz every few seconds and stops sending traffic to a server that fails several in a row. With checks every 5 seconds and two failures required, a dead server can still receive requests for about 10 seconds, so clients need sensible retries. It can use added servers once they are provisioned and registered.

Size the pool for loss, not just for load. If each server handles 300 requests per second and the peak is 900, three servers are exactly enough until one dies. Four servers run at 225 each and rise to 300 after a failure. The balancer also needs a resilient deployment; introducing it does not automatically remove every single point of failure. HAProxy and Nginx are common software choices, and managed options such as AWS Application Load Balancer span multiple zones. For a small internal tool, one larger server may be the better trade.

DECISION POINT

Your one large web server peaks at 80% CPU. The next size up costs twice as much and needs a restart. Do you scale up or out?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • Scale up for simplicity when headroom exists; scale out for larger capacity and redundancy.
  • A load balancer distributes requests; it does not create servers by itself.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
RecallQUESTION 01

Which action is horizontal scaling?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.