AlgoViz

Vertical scaling

easy 18 min

Vertical scaling, or scaling up, means giving one machine more CPU, memory, disk or network so it can handle more load.

See it run

One machine, made bigger: how you find what to grow, what a resize does, what it costs and where it stops.

Operations

Resize a machine

The whole process on one busy server: monitor, identify the bottleneck, plan, schedule, resize, check.

Step 1 of 8

Monitor resources

Our systemrequestsreads, writesUsersxlarge4 vCPU, 16 GBDisk volumesurvives a stop
CPU
92%
Memory
61%
Disk space
48%

Dashboards and alerts track CPU, memory, disk and network. CPU has been at 92% for an hour and requests are slow.

Step 1: Monitor resources

def resize(instance, target):    wait_for_window(instance)        # agreed maintenance window    snapshot(instance.volume)        # a way back    stop(instance)                   # downtime starts    set_type(instance, target)    start(instance)    wait_until_healthy(instance)     # downtime ends    compare_metrics(instance)        # did the bottleneck move?
Downtime
2-10 min
Code change
None
Add a second server
0 min, but the app must be stateless

The resize itself is easy. The plan around it (window, snapshot, rollback) is what interviewers want to hear.

In the real world

The same vertical scaling doing real jobs. Pick one and step through it.

A shop on one server has a holiday sale in a week and no time to redesign.

Step 1 of 4

Monday

Our systemrequestsreads, writesUsers2xlarge8 vCPU, 32 GBDisk volumesurvives a stop
CPU
60%
Memory
50%
Disk space
40%

Normal traffic uses 60% of CPU. The sale should triple it. That does not fit.

Step 1: Monday

Common mistakes

The bugs interviewers watch for, with the fix beside each.

  • Buying a bigger machine before finding the bottleneck

    critical

    If the app waits on a slow query or a lock, more cores sit idle. You pay double and nothing gets faster.

    Wrong
    if p99 > slo:    resize(server, next_size(server))
    Right
    need = bottleneck(usage)if need is None:    profile()                 # queries, locks, poolselse:    resize(server, cheapest_fix(CATALOG, server.type, need))
  • Picking by one resource only

    major

    The smallest type with more CPU may have less memory than today. The resize then causes an out-of-memory crash.

    Wrong
    min(bigger_cpu, key=lambda t: t.cpu)
    Right
    fits = [t for t in bigger_cpu if t.memory >= now.memory]min(fits, key=lambda t: t.price)
  • Calling it high availability

    critical

    One bigger server is still one server. It fails, patches and reboots like the small one did.

    Wrong
    servers = [huge]               # "99.99%"
    Right
    servers = [primary, standby]   # scale up AND replicate
  • Forgetting the app's own limits

    minor

    Worker counts, heap size and buffer caches are often fixed in config. The new memory stays unused until you raise them.

    Wrong
    resize("64GB")# shared_buffers still 4GB
    Right
    resize("64GB")set("shared_buffers", "16GB")  # then restart and measure

Interview tips

  • How to explain it

    • Scaling up: more CPU, RAM, disk or network on one machine.
    • Simple and strongly consistent, because there is nothing to coordinate.
    • Limited by hardware, needs a restart, and stays a single point of failure.
  • Memory trick: UP

    • U is for Upgrade: add CPU, RAM or disk.
    • P is for Power: one more powerful machine.
    • Vertical = UP = upgrade the power of a single machine.
  • Reach for it when

    • A single-node database or a legacy app that cannot be split.
    • Traffic fits comfortably on one machine.
    • You need relief this week and a redesign later.
  • Move on when

    • You are on the largest type, or two rungs away.
    • Downtime for a resize is not acceptable.
    • Users are spread across the globe, or one failure must not stop everyone.