Skip to content

Scalability Basics

How a system copes with more users. Scaling up vs scaling out, latency vs throughput, and why fast is not the same as scalable.

beginner25 minAsked oftenScalabilityHorizontal scalingVertical scalingLatencyThroughput

Last reviewed 24 Oct 2026 · by TheLearningLoop Team

Progress is saved on this device. Create a free account to keep it everywhere.

On this page ▾

Key takeaways

  • Scaling up makes one machine bigger and has a ceiling. Scaling out adds machines and also survives a failure.
  • Latency is how long one request takes. Throughput is how many requests finish per second. They are not the same, and latency climbs sharply as a server nears full.
  • A fast system is not necessarily a scalable one. Scalable means performance holds up as load grows.

Why you need to think about scale, and when to act

A system that works for 100 users can fall over at 100,000. The code is the same, but one machine runs out of CPU, memory or network, requests queue up, and users see slow pages and errors. Scalability is a system's ability to keep working well as the load grows.

Planning for it gives you two things interviewers always ask about:

  • Capacity: handle more requests per second as demand grows, without a rewrite.
  • Availability: keep serving when a machine fails, because there is more than one.

Think about scale when:

  • Traffic is growing, or has peaks such as a sale, a launch or a live event.
  • You have a target, such as "10 times today's traffic", or a latency promise to users.
  • One machine is a single point of failure and downtime is costly.

Skip the heavy machinery, or keep it simple, when:

  • You are small and one server is enough: measure first. Early scaling work costs time and money.
  • The problem is a slow query or slow code: fix that before adding machines. Performance problems and scalability problems are different (see below).
  • Traffic is small and steady: a bigger machine (scale up) is often the simplest fix.

Try it

Pick how the system reacts as traffic changes, then step through the 16 ticks. Watch the capacity line chase the load line, and what happens to latency.

Scaling up and scaling out

Step 1 of 17 · Press Space to play, arrow keys to step
Reaction:
Traffic:
0100200300400- - load (demand)— capacity
  • Server 1
    100 req/s
    serving

Start: one server that handles 100 requests per second. Traffic will change over 16 ticks. Pick how the system reacts, then step through.

load (req/s):
0
capacity (req/s):
100
servers:
1

1 tick = one step of the simulation. Load and capacity are requests per second. Latency is a simple model: it climbs steeply as a server nears full, and a request that cannot be served times out at 3000 ms.

Things to try:

  • Steady growth with Do nothing: traffic outgrows the single server early and 1,440 requests per second are dropped in total. Switch to Scale out: the servers keep up, nothing is dropped, and the worst latency is 200 ms.
  • Steady growth with Scale up: each upgrade needs a restart, so the service is down for a tick each time, and 300 requests per second are dropped. A bigger machine is not free of downtime.
  • Tick the box Crash a server at tick 9. With Scale out nothing is dropped and the worst latency doubles to 400 ms. With Scale up a crash costs far more, because there was only one server: 740 are dropped in total.
  • Sudden spike with Scale out: it still drops 450, because the new servers only arrive after the spike has hit. Autoscaling reacts, it does not predict.

Scaling strategies

StrategyHow it worksGood whenWeakness
Scale up (vertical)Move to a bigger machine: more CPU, memory or diskSimple apps, databases that are hard to split, quick fixesA ceiling (the biggest machine), often downtime to resize, one machine is still a single point of failure
Scale out (horizontal)Add more machines and spread the loadWeb and API servers, anything statelessNeeds a way to spread traffic and servers that do not keep user state; more moving parts
Reactive autoscalingAdd or remove machines automatically when a measurement such as CPU crosses a limitTraffic that changes graduallyReacts after load arrives, and new machines take time to start
Scheduled or pre-scalingAdd machines before a known peak, on a timetable or ahead of an eventPredictable peaks: sales, launches, daily rushesNeeds you to know when the peak comes; wasteful if you guess wrong

Latency vs throughput, and performance vs scalability

  • Latency is how long one request takes, for example 120 ms. Throughput is how many requests finish per second, for example 2,000. A system can have low latency and low throughput, or the reverse.
  • Utilisation links them. When a server is quiet, latency is steady. As it nears full, requests queue, and latency climbs steeply. This is why systems are run well below 100% busy.
  • Performance is how fast the system is for one user or one request. Scalability is whether that performance holds as load grows.

A system with a performance problem is slow even for a single user. A system with a scalability problem is fast for one user and slow under load. The fixes differ: optimise code and queries for the first, add capacity or spread work for the second.

How autoscaling decides

Autoscaling follows a loop, and every step has a delay:

  1. Measure a signal every so often, such as average CPU, requests per second or queue length.
  2. Compare it with a target, for example "keep average CPU near 70%".
  3. Decide how many machines are needed, within a minimum and a maximum you set.
  4. Start new machines. They take time to boot, load the app and pass health checks.
  5. Wait before scaling again, so the system does not flap up and down.

Because of the delays, the system always trails demand a little. That is why you keep headroom (run below the target), set a sensible minimum, and use pre-scaling for known peaks. The maximum protects your budget.

Scaling up vs scaling out vs the alternatives

ConcernScale outScale upOptimise the codeOver-provision
Survives a machine failureYesNoNoOnly if there is more than one machine
Has a hard ceilingNo, in practiceYesYesSet by what you bought
Needs app changesUsually (stateless servers)NoYes, by definitionNo
Downtime to change sizeNoneOften a restartNoneNone
Cost when quietLow with autoscalingPays for the big machineLowestHigh
Best forWeb and API tiersQuick fix, databasesSlow code and queriesKnown, short, critical peaks

Optimising is always worth doing first when something is slow for one user. Scaling out is the long-term answer for growth, and scaling up is the fastest answer for today.

Avoiding a new single point of failure

Scaling out spreads the app servers, but it moves the weak spots elsewhere:

  • The load balancer in front of the servers must itself be redundant.
  • Shared state such as sessions has to live outside the servers, in a shared store, or any server can no longer serve any user.
  • The database is usually the next bottleneck and the next single point of failure. Plan for read replicas, caching and, later, sharding.

The trade-off: you gain capacity and resilience, and you accept more machines to run, more network calls and harder debugging.

Common mistakes

  • Scaling the wrong tier. Adding web servers does nothing if the database is the bottleneck. Measure to find the slow part first.
  • Keeping state on the server. Sessions or files stored on one machine stop it being replaceable. Move them to a shared store.
  • Quoting averages only. Averages hide slow requests. Track the slowest few percent of requests (p95 or p99).
  • Trusting autoscaling for sudden spikes. It reacts late. Pre-scale for known events and keep headroom.
  • No maximum. A bug or an attack can scale you into a huge bill. Always set a limit and an alert.
  • Running near 100% busy. Latency explodes close to full. Aim for comfortable headroom.

How to talk about scalability in an interview

  • Start with numbers: users, requests per second, data size, and the latency target. Say which you are assuming.
  • Prefer scale out for stateless tiers and say why: no ceiling, survives a failure.
  • Say where the next bottleneck is, usually the database, and name the fix: cache, replicas, sharding.
  • Mention failure and spikes unprompted: redundancy, health checks, headroom and pre-scaling.
  • Name the trade-off: more machines to run in return for capacity and resilience.

Where you meet scaling in real systems

Every busy service scales in some way. Here are three drawn out, the first with configuration you can run, then more examples.

Example 1: A web service that adds copies when it is busy

A typical web service runs as several identical copies, and a controller adds copies when CPU is high and removes them when it is quiet. In Kubernetes the controller is the Horizontal Pod Autoscaler. With Docker Compose you set a fixed number of copies. Open the example below to see the picture and the configuration.

Config: run several copies and scale them automaticallySetup 1 config fileCode no code changes
Measure CPUevery few secondsCompare to targetfor example 70%Add or remove copieswithin min and maxNew copies startthis takes time
The autoscaler measures average CPU, compares it with the target, and asks for more or fewer copies, between the minimum and the maximum you set.
# Kubernetes: keep between 2 and 8 copies of the app and add copies when CPU is busy.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 2                       # start with two copies, so one can fail without an outage
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: web
          image: registry.example.com/web:1.0   # placeholder image
          resources:
            requests:
              cpu: 250m             # the autoscaler measures CPU against this request
              memory: 256Mi
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: web
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: web
  minReplicas: 2                    # never fewer than two
  maxReplicas: 8                    # a cost and safety ceiling
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70    # add copies when average CPU goes above 70% of the request

The Kubernetes manifests were checked with kubeconform in strict mode and the Compose file with docker compose config. The image name is a placeholder, and the numbers are examples to adjust for your own service.

Example 2: Scaling out behind a load balancer

To scale out, put several identical servers behind one address. The load balancer spreads requests and stops sending to a failed server. Because every server is the same and keeps no user data, any server can answer any request.

ClientsLBS1S2S3
Clients talk to one address. The load balancer shares the requests across three identical servers. To add capacity, add a server behind it. See the Load Balancer lesson for how it chooses.

Example 3: Losing a machine

With four servers sharing the load, losing one removes a quarter of the capacity. That hurts, but the service stays up. With one big machine, losing it removes all of it.

Before100100100100After one crash100100down100
Each box is a server that handles 100 requests per second. After one crashes, 300 remain, so capacity falls by a quarter instead of to zero.

More real-world scenarios

4. Sales and ticket launches

A shop or a ticket seller knows when a big sale starts. Teams add servers and warm caches before the start time, because autoscaling alone would arrive after the rush has already begun.

5. Live events and streaming

A live stream can go from a few viewers to a very large audience in minutes. Providers spread the work across many servers and use content delivery networks so that most viewers are served from nearby copies.

6. Ride-hailing and delivery apps

Demand has daily peaks, such as commuting hours and mealtimes. Autoscaling adds capacity for the peaks and removes it afterwards, so the company does not pay for idle machines overnight.

7. Game launches

A new game or a big update can bring a crowd of players at once. Studios often run load tests ahead of launch and pre-scale their servers, since a failed launch day is hard to recover from.

8. Results days and deadlines

Exam results, tax deadlines and ticket drops send a burst of users in a short window. Services queue requests, show waiting rooms and scale ahead of time to keep the site usable.

9. Batch data pipelines

A nightly job that processes a large file can be split into pieces and run on many workers at once. Scaling out turns an eight-hour job into a much shorter one, and the workers disappear when it finishes.

10. A startup that outgrows its first server

Many products start on one machine and scale up for the first growth. Later they move to several servers behind a load balancer, with the database on its own machine, and finally add replicas and caching.

Tools and managed services

KindNameNotes
Open sourceKubernetes Horizontal Pod AutoscalerScales copies of an app by CPU, memory or custom measurements
Open sourceKEDAScales Kubernetes workloads from events such as queue length
AWSAmazon EC2 Auto ScalingAdds and removes virtual machines in a group
Google CloudCompute Engine managed instance groups with autoscalingScales a group of identical virtual machines
AzureVirtual Machine Scale SetsScales a set of identical virtual machines

The takeaway

Whenever a design needs to handle growth or survive a failure, the first box you draw is several identical servers behind a load balancer, with the state moved out of them.

Interview questions

Try answering out loud before you reveal hints. Interviewers care about how you reason, not just the final answer.

  1. 1.

    Your service is slowing down as traffic grows. Would you scale up or scale out, and why?

    easy
  2. 2.

    Explain the difference between latency and throughput, and why latency rises when a server gets busy.

    easy
  3. 3.

    Traffic doubles within a minute and your autoscaler reacts too late. How do you survive it?

    medium
  4. 4.

    You are asked to design a system for ten times today's traffic. Where do you look for bottlenecks first?

    medium
  5. 5.

    What is the difference between a performance problem and a scalability problem?

    easy

↑ Back to top

Next lesson