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.
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?
Scaling up is quick and changes no code, but it keeps the single point of failure and has a ceiling. Scaling out needs a load balancer and servers that hold no unique user state, and in return it adds redundancy. If an outage is costly, scale out; if downtime is tolerable, scaling up buys time cheaply.
Use this as a guide for self review; written answers are not graded.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.