Skip to content
Visual explainer 2h to learn 3 steps

Latency, throughput, availability & SLAs

Translate 'four nines' into allowed downtime and reason about latency percentiles.

By Invicly Tech, , in System Design Deep Dive. About 10 minutes to read.

Topic 3 of 33

In short

Latency is how long one request takes, throughput is how many requests you handle per second, and availability is the fraction of time the system works. SLAs, SLOs and SLIs turn these into measurable promises.

Think of it like this: A highway: latency is trip time, throughput is cars per hour, availability is how often it is open.

Explained simply

Three words describe how well a system performs. Latency is how long you wait for one answer. Throughput is how much work gets done each second. Availability is how often the system works at all.

Picture a coffee shop. Latency is the time from ordering to holding your coffee. Throughput is cups served per hour. Availability is whether the shop is open. A shop can serve 200 cups an hour and still make each customer wait five minutes, so the two numbers are different.

Not every request is equally fast. If you line up all requests from fastest to slowest, the one 95 percent of the way along is the p95. Users remember the slow moments, so teams watch these upper percentiles closely.

Teams turn these ideas into promises. They measure something (an SLI), aim for a target (an SLO) and sometimes sign a contract with customers about it (an SLA). This turns "the site feels slow" into a number everyone can agree on.

Press Play on a diagram to walk through it one step at a time.

CompareNines of availability
99.9% (three nines)
  • About 8.8 hours down per year
  • About 43 minutes per month
  • Typical for internal tools
99.99% (four nines)
  • About 53 minutes down per year
  • About 4.3 minutes per month
  • Needs redundancy and automated failover
99.999% (five nines)
  • About 5 minutes down per year
  • About 26 seconds per month
  • Very costly, multi-region required
LayersSLI, SLO and SLA
  1. 1
    SLA

    Contract with customers, with penalties if missed

  2. 2
    SLO

    Internal target, stricter than the SLA

  3. 3
    SLI

    The measured metric, such as success rate

FlowHow one slow dependency takes a server down
  1. 1
    Database slows down

    Latency goes from 0.2 s to 2 s

  2. 2
    Requests pile up

    Little's Law: 10× more in flight

  3. 3
    Threads run out

    All workers wait on the database

  4. 4
    New requests queue

    Even healthy endpoints become slow

  5. 5
    Timeouts everywhere

    Users see errors, retries add more load

CompareTuning for latency vs throughput
Lower latency
  • Handle each request right away
  • Keep servers lightly loaded
  • Cache close to the user
  • Costs more machines per request
Higher throughput
  • Batch work together
  • Keep servers busy
  • Queue and process in bulk
  • Each item may wait longer

In depth

Little's Law: how latency and throughput connect

Little's Law says the number of requests in progress equals throughput times latency. A service handling 1,000 requests per second, each taking 0.2 seconds, has about 200 requests in flight at any moment.

This explains a common outage. If a database slows down and latency jumps from 0.2 to 2 seconds, the same traffic now needs 2,000 requests in flight. If the server only has 500 worker threads or connections, new requests start queueing, time out and fail, even though the server's CPU looks idle. Slowness turns into an outage.

CompareLittle's Law: same traffic, slower database
Normal
  • 1,000 requests/s x 0.2 s
  • 200 requests in flight
  • 500 workers: plenty of room
Database slows down
  • 1,000 requests/s x 2 s
  • 2,000 requests in flight
  • 500 workers: queueing and timeouts

Why latency explodes when servers get busy

When a server is lightly used, a new request starts immediately. As it gets busier, requests wait in a queue first. Simple queueing models show the average time in the system is roughly the work time divided by (1 minus utilisation).

At 50 percent busy, requests take about twice as long as the work itself. At 90 percent, about ten times. At 99 percent, about a hundred times. Latency does not grow gently; it shoots up near the limit. This is why capacity plans keep servers around 60 to 70 percent busy at peak.

  • 50% busy → ~2× the work time
  • 90% busy → ~10×
  • 99% busy → ~100×

Tail latency gets worse with fan-out

Many pages call several backends at once and wait for all of them. If each backend is slow 1 percent of the time, a page that calls 100 of them hits at least one slow call 1 − 0.99^100 ≈ 63 percent of the time. The rare slow case for one service becomes the normal case for the user.

Fixes include calling fewer services, caching results, setting tight timeouts and returning partial results, and hedged requests: if a reply has not arrived by the p95 time, send the same request to a second replica and use whichever answers first.

Measuring percentiles correctly

You cannot average percentiles. If server A reports p99 of 100 ms and server B reports 300 ms, the overall p99 is not 200 ms. It depends on how many requests each served and how they were spread.

The right approach is to record a histogram, a count of requests in latency buckets such as 0–10 ms and 10–25 ms, on every server. Histograms can be added together, and the percentile is computed from the merged result. Prometheus histograms and HdrHistogram work this way. Also measure from the client side when you can, because it includes network and queueing time that server timers miss.

FlowGetting a fleet-wide p99 right
  1. Step 1
    Record histograms

    Counts per latency bucket on every server

  2. Step 2
    Collect them

    e.g. Prometheus histograms

  3. Step 3
    Add bucket counts

    Histograms can be summed

  4. Step 4
    Compute p99

    From the merged histogram, not by averaging

Counting availability honestly

There are two common ways to count availability. Time-based counts the minutes the system was up. Request-based divides successful requests by valid requests, which better matches what users feel during a partial outage.

Decide up front what counts as a failure. Server errors (5xx) and responses slower than the target usually count. Client mistakes such as a 404 for a page that does not exist usually do not. Planned maintenance still feels like downtime to users, so many teams count it too.

Learn it in 3 short steps

About 40m each. Track them with a timer in your plan.

  1. 1
    Convert nines into allowed downtime~40m
  2. 2
    Explain p50, p95 and p99 latency~40m
  3. 3
    Distinguish SLAs, SLOs and SLIs~40m

Key points

  • Report latency as percentiles; averages hide slow outliers.
  • p99 means 99% of requests are faster than this value.
  • Each extra nine cuts allowed downtime by a factor of ten.
  • Components in series multiply availability, so more dependencies lower overall uptime.
  • Set SLOs stricter than SLAs to leave a safety margin.

Key terms

Tap a card to flip it. 0/6 known

Examples

text
Two services in series, each 99.9% available:
  0.999 * 0.999 = 0.998  -> 99.8%

Two redundant replicas, each 99%:
  1 - (0.01 * 0.01) = 0.9999 -> 99.99%

Allowed downtime at 99.95% per 30 days:
  0.0005 * 30 * 24 * 60 = 21.6 minutes

Series lowers availability; redundancy raises it.

Why the average lies

Ten requests are measured. Nine take 11 to 16 ms and one takes 900 ms because of a slow disk. The average is 102 ms, a number that describes no real request. The p50 is 13 ms (what a typical user sees) and the p90 is 16 ms, while the p99 exposes the 900 ms outlier. The nearest-rank method below sorts the values and picks the item at position ceil(p/100 × n).

python
import math

times_ms = [12, 15, 11, 14, 13, 16, 12, 900, 14, 13]

def percentile(values, p):
    s = sorted(values)
    rank = math.ceil(p / 100 * len(s))  # nearest-rank method
    return s[rank - 1]

print(sum(times_ms) / len(times_ms))  # 102.0
print(percentile(times_ms, 50))       # 13
print(percentile(times_ms, 90))       # 16
print(percentile(times_ms, 99))       # 900

Writing an SLO for a checkout API

Step 1, choose the SLI: the share of POST /checkout requests that return a non-5xx response within 500 ms, measured at the load balancer. Step 2, set the SLO: 99.9 percent over a rolling 30 days. Step 3, compute the error budget: with 2 million checkouts a month, 0.1 percent means 2,000 bad requests are allowed. Step 4, set the external SLA lower, say 99.5 percent with service credits, so a bad week does not breach the contract. Step 5, alert when the budget is burning fast, for example 10 percent gone in one hour.

Quick reference

  • Little's Law: requests in flight = throughput × latency
  • Keep servers below ~70% busy at peak; queueing delay explodes above that
  • Never average percentiles; merge histograms, then compute the percentile
  • Chance a fan-out of N calls hits a slow one = 1 − (1 − p)^N
  • Request-based availability = good requests ÷ valid requests
  • Downtime per year ≈ (1 − availability) × 525,600 minutes
  • SLA target < SLO target < what you normally achieve

Common mistakes

  • Quoting average latency when users feel the tail.
  • Promising an SLA equal to your SLO with no buffer.
  • Forgetting that a page calling many services sees the worst tail.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1A service handles 2,000 requests per second with 50 ms latency. How many requests are in flight on average?

Question 2

2What happens to waiting time as a server goes from 50 percent to 95 percent busy?

Question 3

3Server A's p99 is 100 ms and server B's is 300 ms. What is the combined p99?

Question 4

4A page calls 50 services in parallel, each slow 1 percent of the time. Roughly how often is the page slow?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Convert 99.95 percent availability into allowed downtime per 30-day month and per year.

  2. Exercise 2medium

    A service gets 500 requests per second with an average latency of 80 ms and has 200 worker threads. The database suddenly slows and latency becomes 1 second. What happens, and what would you do?

  3. Exercise 3hard

    A page calls 20 services in parallel. Each has p50 of 20 ms and p99 of 300 ms. Estimate how many page loads wait at least 300 ms, then propose two fixes.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

What is a good latency for a web API?
For user-facing calls, many teams target p99 under 200 to 300 ms on the server. Under about 100 ms feels instant to people, while over a second feels slow.
Is 100 percent availability possible?
No. Networks, hardware and deployments all fail sometimes, and each extra nine costs much more. Teams choose a target that users actually need.
Why watch p99 instead of the maximum?
The maximum is often one freak event, like a garbage collection pause, and jumps around a lot. p99 and p99.9 are stable enough to set targets on while still showing the slow tail.

Go deeper

ShareXLinkedInWhatsApp