Course contents

03. Scaling and Load Balancing Lesson 1 of 8

Vertical Scaling

Scale up one machine: what more cores and faster CPUs buy, why the bottleneck moves, and the size ceiling, cost curve and downtime of scaling up.

12 minBeginner10 steps
Loading the interactive simulation…
Loading the knowledge check…

Summary

  • Vertical scaling (scaling up) gives one machine more cores, faster cores, more memory or faster storage.
  • More cores raise throughput; only faster cores or less work per request lower single-request latency.
  • Upgrading one component moves the bottleneck to the next; resize the one that is saturated.
  • Every provider has a largest size, and the top sizes cost the most per unit of capacity.
  • One machine is a single point of failure, and resizing it usually means a restart.
Deep diveHow it works, trade-offs, failure modes, misconceptions and the interview angle.

What it is

Vertical scaling, or scaling up, means making a single machine more powerful: more CPU cores, faster cores, more memory, faster disks or a faster network card. The application keeps running as one instance at one address; only the hardware underneath changes. On a cloud provider it usually means switching the instance type; on your own hardware it means a bigger server.

Why it exists

It is the simplest way to get more capacity. No code changes, no load balancer, no data split across machines, no new failure modes between nodes. For many systems, especially relational databases, one large machine is far easier to operate than a cluster, and modern servers are big enough to carry a surprising amount of traffic.

How it works

The capacity of a machine is roughly parallel slots ÷ time per request. A server with 8 cores, where each request needs 40 ms of CPU, completes at most about 8 × (1000 / 40) = 200 requests per second. Each resource you add changes one side of that formula:

  • More cores (or threads, or worker processes) add parallel slots. Throughput rises; a single request at low load is not any faster.
  • Faster cores shorten the time per request. Both latency and throughput improve, but single-core speed grows slowly from one hardware generation to the next.
  • More memory lets a database keep more of its working set in RAM, turning disk reads into memory reads. That shortens time per request too, often dramatically.
  • Faster storage and network help when the work is I/O-bound rather than CPU-bound.

Which one helps depends on what is saturated. A request also waits on everything it calls: if the app holds a worker while it waits for a database connection, adding app cores only adds more waiters.

When to use it

  • Early in a product's life, when one machine has plenty of headroom and simplicity matters most.
  • For stateful components that are hard to distribute: relational databases, search indexes, stateful legacy applications.
  • As a quick fix for a measured bottleneck while a longer-term change (caching, read replicas, sharding) is prepared.
  • When software licences or the workload itself (large in-memory datasets) favour fewer, larger machines.

When not to

  • When you need high availability: one machine cannot survive its own failure.
  • When growth will clearly outrun the largest available size.
  • When the bottleneck is elsewhere, such as a downstream database, an external API or lock contention inside the application. More hardware for the wrong component changes nothing.
  • When the application cannot use extra cores (a single-threaded process, a global lock).

Trade-offs

Choice You gain You pay
Scale up instead of out No code changes, no distributed-systems problems Size ceiling, single point of failure
Larger instance size More capacity immediately Higher cost per unit near the top; a restart to resize
More cores Throughput Nothing for single-request latency; only helps parallel workloads
More memory for a database Fewer disk reads, lower latency Cost; longer warm-up after a restart (cold cache)

Alternatives

  • Horizontal scaling: many smaller machines behind a load balancer. More headroom and fault tolerance, but the application must be stateless or its state partitioned.
  • Caching: avoid the work instead of buying capacity for it.
  • Read replicas: copy a database to extra machines for reads, keeping one primary for writes.
  • Making the work cheaper: a missing index or an N+1 query pattern often costs more than any instance upgrade would save.

Failure modes

  • Wrong component resized: the saturated resource is the database pool, a lock or a downstream service, so the bigger machine sits idle while errors continue.
  • Resize downtime: changing instance type stops and starts the machine; with one instance, every request in that window fails.
  • Cold start after resize: caches and buffer pools are empty after the restart, so the first minutes are slower than before the upgrade.
  • No next size: growth reaches the largest instance and there is nowhere left to go at short notice.
  • Software that cannot use the hardware: a single-threaded process, a connection pool sized for the old machine or a JVM heap that was never raised leaves the new resources unused.

In production

Measure before resizing: per-core CPU, memory pressure, disk queue depth, connection pool waits and per-dependency latency show which resource is actually saturated. Resize during a maintenance window, behind a failover replica, or after moving traffic to a standby, so the restart is not an outage. Revisit thread pools, connection pools and memory settings after a resize so the software uses the new capacity. Keep an eye on the cost curve: the largest instances are often priced well above twice the cost of half their size. Most mature systems combine both directions: scale the stateful core up and the stateless tiers out.

Common misconceptions

  • "A bigger machine makes everything faster." More cores raise throughput; a single request at low load takes as long as before unless the cores themselves are faster or the work gets cheaper.
  • "Vertical scaling is old-fashioned." Many large systems run their primary database on one very large machine because it is simpler and consistent.
  • "Doubling the cores doubles the capacity." Only if the bottleneck was CPU and the work is parallel. Locks, I/O and downstream services cap the gain.
  • "Enough capacity means enough availability." A single machine is still one failure away from a full outage.

Interview angle

A good answer starts simple: "one well-sized machine handles this; here is the arithmetic." Then show you know the limits: the largest instance, the cost curve, the single point of failure and downtime on resize. Interviewers like to hear where you would scale up (the database, at first) and where out (stateless app servers), and that you would find the bottleneck before buying hardware.

Model assumptions

The simulation is a simplified model, not a benchmark. The app server starts with 2 workers (one per core) and a 50 ms mean service time (lognormal, cv 0.35), with room for 10 waiting requests; "more cores" raises the number of workers and "faster cores" halves the service time. App workers stay occupied while they wait for the database. The database's capacity is its connection pool (3, later 12 connections) with 25 ms (later 15 ms) per query and a 200 ms pool timeout. Arrivals are random (Poisson); network hops take a fixed 2–20 ms. A resize is modelled as the server being down for 2 seconds. Utilisation is the fraction of busy workers, not CPU. Numbers show behaviour and orders of magnitude only.

The lesson as textEvery step of the simulation, written out.
  1. 1. A small server with two cores

    Users send about 20 requests per second to one application server. It has two cores, so it works on two requests at once, and each takes about 50 ms of CPU time.

    That gives it a ceiling of roughly 40 requests per second. At 20 it is about half busy and every request succeeds.

    Scene: Users connect directly to one application server with two cores. It is about half busy and every request succeeds.

    Key idea: Capacity of one machine ≈ parallel slots ÷ time per request.

  2. 2. Traffic outgrows the box

    One second in, traffic doubles to 50 requests per second, more than the 40 the server can finish.

    Both cores are busy all the time, the waiting line fills and the server starts rejecting requests with 503. The quickest fix most teams reach for: a bigger machine.

    Scene: Traffic rises to 50 requests per second. The two-core server is fully busy, its queue is full and some requests are rejected.

    Key idea: When demand exceeds one machine’s capacity, requests queue and then fail.

  3. 3. Scale up: eight cores instead of two

    We move the application to an instance with eight cores. Nothing else changes: same code, same address, no load balancer.

    The server can now work on eight requests at once, about 160 per second. At 50 requests per second it is around 30% busy and the rejections stop. Notice what did not change: a single request still takes about as long as before.

    Scene: The server now has eight cores. At 50 requests per second it is about 30% busy, nothing is rejected, and median latency is about the same as with two cores at low load.

    Key idea: More cores raise throughput. They do not make one request faster.

  4. 4. A faster CPU shortens every request

    Next we pick an instance family with cores twice as fast. Each request now needs about 25 ms of CPU instead of 50.

    This time the median latency drops, because every request finishes sooner. Faster cores help both latency and throughput; more cores help only throughput. In practice single-core speed improves slowly, so most of what you can buy is more cores and more memory.

    Scene: The server’s cores are twice as fast. Median latency drops by about 25 ms and the server is about 15% busy.

    Key idea: Faster cores cut per-request time; more cores add parallel slots.

  5. 5. The bottleneck moves to the database

    Real requests also read from a database. Ours keeps a pool of three connections and needs about 25 ms per query, so it can answer roughly 120 queries per second.

    Traffic grows to 150 requests per second. The app’s workers now spend most of their time waiting for a free database connection, not computing. All of them are occupied, the app’s queue fills and requests are rejected, even though each request needs only about 12 ms of CPU.

    Scene: The app server now reads from a database with three connections. At 150 requests per second the database is saturated, the app’s workers are stuck waiting for it and some requests are rejected.

    Key idea: Scaling one component only moves the bottleneck to the next one.

  6. 6. A bigger app server changes nothing

    A tempting reaction is to scale up the app server again, to sixteen cores.

    Throughput barely moves, requests are still rejected and P95 latency even gets worse. The app was never the limit: more app workers simply wait in line for the same three database connections. Before you buy a bigger machine, find out which one is saturated.

    Scene: The app server has sixteen cores, but the database is still saturated. Throughput hardly rises and requests are still rejected.

    Key idea: Upgrade the component that is saturated, not the one that is easiest to resize.

  7. 7. Scale up the database instead

    Now we resize the database: more CPU and memory let it hold twelve connections, and faster storage cuts a query to about 15 ms. Its capacity jumps to roughly 800 queries per second.

    The app’s workers are freed, the rejections stop and all 150 requests per second succeed. Vertical scaling works well while there is a bigger size to move to, and for a database it is often the simplest first step.

    Scene: The database is larger: twelve connections and faster queries. Nothing fails at 150 requests per second.

    Key idea: Vertical scaling is the easiest win for stateful components, as long as a bigger size exists.

  8. 8. There is no bigger machine

    Business keeps growing: 900 requests per second. Both machines are already the largest size our provider sells.

    The app server saturates again and requests are rejected, and this time there is no next size to buy. The biggest instances also cost far more per unit of capacity than mid-sized ones. This hard ceiling is why large systems eventually scale out instead of up.

    Scene: Traffic rises to 900 requests per second. The largest app server is saturated and requests are rejected.

    Key idea: Vertical scaling has a hard upper limit, and the last steps are the most expensive.

  9. 9. Resizing means a restart

    Back at 150 requests per second, the team schedules another resize. Changing an instance type usually means stopping and starting the machine.

    One second in the app server goes down; it comes back two seconds later. With only one machine, every request in that window fails. The same happens on a crash or a kernel patch: one big machine is one big single point of failure.

    Scene: The app server restarts for a resize. For two seconds every request fails because there is no other server; then it recovers and requests succeed again.

    Key idea: One machine, however large, is a single point of failure, and resizing it causes downtime.

  10. 10. When scaling up is the right call

    Scale up first when it is cheap: no code changes, no distributed-systems problems, and databases in particular are much simpler on one node. Measure which component is saturated before you resize.

    Plan for its limits: a ceiling on size, steeply rising cost near the top, and downtime for every resize or crash. The next step is horizontal scaling: many smaller machines behind a load balancer.

    Scene: The app server and the large database serve 150 requests per second without errors.

    Key idea: Scale up for simplicity, scale out for headroom and availability.