Pidoku

SLOs, SLIs, and Latency Budgets

Module 23 Lesson 23.a 1h 15m Difficulty 3/5

Prerequisites 2.c, 20.c


Before you start: words you need#

WordPlain meaning
SLIService level indicator: a measurement of the service, such as “95th-percentile time to first token over 5 minutes”.
SLOService level objective: a target for an SLI, such as “p95 time to first token below 800 ms”.
SLAService level agreement: a promise in a contract, with money or credits owed if it is broken.
p95 / p99The 95th / 99th percentile: the value that 95% / 99% of requests are faster than.
TTFTTime to first token: from sending the request to seeing the first word (2.c).
ITLInter-token latency: the gap between one streamed token and the next (2.c).
GoodputThe share of requests (or tokens) that met all their latency objectives, not just some.
Error budgetThe amount of failure the SLO allows, e.g. 0.1% of requests in 30 days. You may “spend” it.

1. What is it?#

Three related words describe how reliable and fast a service promises to be:

SLI  a measurement           "p95 TTFT over 5 minutes"
SLO  a target for an SLI     "p95 TTFT < 800 ms"
SLA  a contract              "if monthly availability < 99.9%, you get a 10% credit"

A latency budget splits one latency objective into pieces (network, gateway, queue, prefill, and so on), gives each piece a share, and names who owns it.

For an LLM service, all three need more care than for an ordinary web service, because “latency” is not one number and “success” is not just an HTTP 200.


2. Why does it exist?#

Without written objectives, every reliability argument is opinion: “is 2 seconds slow?”, “should we ship on Friday?”, “do we need more GPUs?”. An SLO turns those into arithmetic.

LLM services break the usual assumptions:

ORDINARY SERVICE                LLM SERVICE
one latency metric              TTFT and ITL are separate experiences
requests cost about the same    cost varies 1,000x with prompt and output length
success = 2xx                   success also means "the answer was good"
latency roughly stable          latency depends on prompt length and output length

A single “p99 latency < 2 s” objective is meaningless here. Every long generation breaks it, every short one passes it, and it tells you nothing about health.


3. Simple analogy#

A pizza delivery promise has two parts: “the driver leaves within 10 minutes” (TTFT) and “the pizza arrives hot” (ITL, the steady flow once it has started). A shop that promises “delivery in 30 minutes” for every order, whether it is one pizza next door or forty pizzas across town, will either break the promise all the time or pad it so much that it means nothing. Sensible shops promise by order size. LLM services must promise by prompt length for the same reason.


4. Tiny example: goodput is lower than either metric#

Twenty requests. TTFT objective depends on prompt length (≤ 2k tokens: 800 ms; ≤ 16k: 3 s; larger: 12 s). ITL objective: each request’s own p95 gap below 50 ms.

requests meeting TTFT objective:  90%
requests meeting ITL objective:   80%
goodput (meeting BOTH):           70%

Each metric on its own looks tolerable. Only 70% of users had a good experience, because different requests failed different objectives. That is why goodput is computed per request, then counted (the program is in section 6).


5. Technical explanation#

A well-formed LLM SLO#

SERVICE: chat-completions, model "chat-70b", standard tier

AVAILABILITY
  99.9% of eligible requests return a non-5xx response, rolling 30 days

LATENCY — TIME TO FIRST TOKEN (rolling 5-minute windows)
  p95 TTFT < 800 ms     for prompts ≤ 2,000 tokens
  p95 TTFT < 3,000 ms   for prompts 2,001–16,000 tokens
  p95 TTFT < 12,000 ms  for prompts > 16,000 tokens

LATENCY — INTER-TOKEN (rolling 5-minute windows)
  p95 ITL < 50 ms,  p99 ITL < 120 ms

GOODPUT
  ≥ 97% of eligible requests meet BOTH their TTFT and ITL objectives

QUALITY
  each deployed version scores within 2% of the reference on the evaluation suite

EXCLUSIONS
  requests over published limits (max input 32k, max output 4k)
  429 responses (over quota) — counted, but in their own SLI

What makes it good:

  1. TTFT is bucketed by prompt length. Otherwise one user pasting a book breaks the SLO.
  2. ITL has a p99 as well as a p95. The p99 catches stalls such as a long prefill landing in a decode step (12.k, 22.k).
  3. Goodput is the composite. It cannot be gamed by making everyone uniformly slow.
  4. Quality is an objective. For an LLM, “it responded” is not “it worked”.

Reasoning models need one more decision: is TTFT the first visible token or the first token of any kind, including hidden reasoning? Write down which. A model that thinks for 20 seconds before it answers has a fast TTFT by one definition and a slow one by the other; agentic and batch workloads usually care about end-to-end time instead.

Choosing the numbers#

Do not invent thresholds; derive them from what users feel and what the system can do.

TTFT.

What users feel                    What is achievable
< 200 ms   instant                 floor = network + gateway + tokenize + prefill(p95 prompt)
200–500 ms responsive              e.g. 70B model, 2,000-token prompt on 8 GPUs:
0.5–1 s    fine for "thinking"          ~150 ms prefill + ~50 ms network and gateway
1–3 s      needs a progress cue    → an 800 ms p95 leaves ~600 ms for queueing. Reasonable.
> 3 s      users retry or leave

Set the objective where acceptable meets achievable, with headroom.

ITL. People read about 4–5 words a second, roughly 5–7 tokens a second, or 140–200 ms per token. But streaming feels smooth only well below that:

< 30 ms   very smooth         60–100 ms  slightly choppy
30–60 ms  smooth              > 150 ms   visibly slow

p95 ITL below 50 ms is a sound chat target. For agents and batch jobs ITL barely matters; total time does.

Availability.

99.9%   ≈ 43 minutes down per 30 days    N+1 replicas, careful deploys
99.95%  ≈ 22 minutes                     several zones, very careful deploys
99.99%  ≈ 4.3 minutes                    several regions and a lot of engineering

GPU fleets have failure modes web fleets do not (Xid errors, hung collectives, minutes-long cold starts, 23.e). Promise 99.9% and deliver it before promising more. Check what the large API providers actually commit to in their SLAs; it is usually less than people assume.

The latency budget#

Split the objective and give each line an owner:

p95 TTFT budget: 800 ms

  DNS + TCP + TLS (connection reused)       20 ms
  network round trip (same region)          40 ms
  gateway (auth, rate limit, route)         15 ms
  tokenization                               5 ms
  queue wait                               300 ms   ← the flex
  prefill (p95 prompt = 1,800 tokens)      180 ms
  first sample                               2 ms
  first SSE write                            8 ms
  ──────────────────────────────────────────────
  total                                    570 ms    headroom 230 ms

When the SLO is broken, the budget tells you which line grew. Queue wait is the flex line: it absorbs load swings, and capacity planning (23.b) exists to keep it inside its share.

Error budgets#

SLO 99.9% over 30 days → budget 0.1% → 43.2 minutes of full outage

  a 15-minute full outage          → 35% of the budget
  a steady 0.05% error rate        → 50% of the budget, all month
  a bad deploy, rolled back in 8 min → 19%

A written policy says what happens as the budget is spent:

> 50% left      ship normally
20–50% left     ship carefully; reliability work comes first
< 20% left      feature freeze; reliability work only
exhausted       no deploys except fixes

Alert on the burn rate (how fast the budget is being spent), not on the error rate alone. A burn rate of 1 spends the budget exactly over the window; 14 would spend a 30-day budget in about two days. The usual pattern pages on a fast burn over a short window and tickets on a slow burn over a long one.

Consider a quality budget too: how much evaluation-score loss you will accept from optimization work (quantization, speculative decoding, new kernels), spent on purpose.

Measuring the SLIs correctly#

✓ measure at the client side or at the real ingress, not inside the engine
✓ use histograms, never averages
✓ bucket TTFT by prompt length
✓ exclude requests over published limits
✓ count 429s in their own SLI: they are the quota working, not the service failing
✓ compute goodput per request (ttft_ok AND itl_ok), then count
✓ match the measurement window to the SLO window
PromQL
# Goodput: eligible requests that met BOTH objectives, over 5 minutes
sum(rate(llm_requests_total{ttft_ok="true", itl_ok="true", excluded="false"}[5m]))
/ sum(rate(llm_requests_total{excluded="false"}[5m]))

ttft_ok and itl_ok must be decided per request (in the gateway, or from structured logs, 23.h). Two separate histograms cannot give you goodput, because a request can pass one and fail the other.

Tiers#

Different customers need different promises, and different promises need different capacity:

TIER       TTFT p95   ITL p95   Availability   Max context   Priority
free         3 s      120 ms       99.0%           8k          low
standard   800 ms      50 ms       99.9%          32k          normal
premium    400 ms      30 ms       99.95%        128k          high
batch        —          —          99.9%         128k          lowest  (done within 24 h)

Free and batch traffic run at large batch on shared capacity; premium runs at smaller batch on reserved capacity. The machinery is priority classes in the scheduler (20.k), separate replica pools, and admission control that sheds free-tier load first (20.c).


6. Under the hood#

The program behind section 4, plus burn-rate arithmetic for a 99.9% SLO.

Go
// goodput.go — per-request SLO checks, goodput, and error-budget burn rate.
package main

import "fmt"

type request struct {
	promptTokens int
	ttftMs       float64 // time to first token
	itlP95Ms     float64 // this request's own 95th-percentile gap between tokens
}

// ttftLimit returns the TTFT objective for a prompt of this length (bucketed).
func ttftLimit(promptTokens int) float64 {
	switch {
	case promptTokens <= 2000:
		return 800
	case promptTokens <= 16000:
		return 3000
	default:
		return 12000
	}
}

const itlLimit = 50.0 // ms

func main() {
	reqs := []request{
		{500, 310, 31}, {1200, 420, 38}, {800, 650, 61}, {1900, 760, 44},
		{300, 280, 29}, {6000, 2100, 47}, {12000, 2900, 58}, {700, 950, 33},
		{40000, 9800, 49}, {1500, 520, 42}, {900, 390, 36}, {2500, 1300, 40},
		{600, 300, 71}, {1100, 610, 39}, {20000, 13100, 45}, {400, 350, 34},
		{3000, 1500, 48}, {1000, 540, 52}, {800, 470, 37}, {1600, 700, 41},
	}

	ttftOK, itlOK, both := 0, 0, 0
	for _, r := range reqs {
		t := r.ttftMs <= ttftLimit(r.promptTokens)
		i := r.itlP95Ms <= itlLimit
		if t {
			ttftOK++
		}
		if i {
			itlOK++
		}
		if t && i {
			both++
		}
	}
	n := float64(len(reqs))
	fmt.Printf("requests meeting TTFT objective: %3.0f%%\n", float64(ttftOK)/n*100)
	fmt.Printf("requests meeting ITL objective:  %3.0f%%\n", float64(itlOK)/n*100)
	fmt.Printf("goodput (meeting BOTH):          %3.0f%%\n\n", float64(both)/n*100)

	// Error budget: 99.9% availability over 30 days.
	const slo = 0.999
	budget := 1 - slo
	budgetMinutes := budget * 30 * 24 * 60
	fmt.Printf("error budget: %.1f minutes of full outage per 30 days\n", budgetMinutes)
	for _, errRate := range []float64{0.0005, 0.001, 0.005, 0.02} {
		burn := errRate / budget // 1.0 = spending the budget exactly on schedule
		daysLeft := 30 / burn
		fmt.Printf("error rate %5.2f%% → burn rate %4.1fx → whole budget gone in %5.1f days\n",
			errRate*100, burn, daysLeft)
	}
}

Output:

requests meeting TTFT objective:  90%
requests meeting ITL objective:   80%
goodput (meeting BOTH):           70%

error budget: 43.2 minutes of full outage per 30 days
error rate  0.05% → burn rate  0.5x → whole budget gone in  60.0 days
error rate  0.10% → burn rate  1.0x → whole budget gone in  30.0 days
error rate  0.50% → burn rate  5.0x → whole budget gone in   6.0 days
error rate  2.00% → burn rate 20.0x → whole budget gone in   1.5 days

A 2% error rate sounds small. Against a 99.9% SLO it empties the month’s budget in a day and a half, which is why it should page someone.


7. Performance implications#

  • The SLO sets the batch size. A tight ITL objective caps how many sequences can share a decode step, which caps throughput per GPU (2.d). Loosening p95 ITL from 30 ms to 50 ms can raise throughput substantially on the same hardware.
  • The SLO sets the utilization target. The queue-wait share of the TTFT budget decides how hot you can run the fleet before queueing eats it (23.b).
  • Tiers buy efficiency. Free and batch traffic at large batch fill the capacity that premium’s small batches leave idle.

8. Production implications#

  • Write the SLO down and publish it, at least internally; to customers if there is an SLA.
  • Instrument goodput. It is the number that lines engineering up with the product.
  • Keep a latency budget and monitor each line.
  • Use the error budget to govern risk: deploy freezes and reliability work follow the policy, not the loudest voice.
  • Put quality in the SLO, measured at every deployment (23.g).
  • Publish limits (max input, max output, rate limits) and exclude over-limit requests.
  • Review the SLO quarterly against what users actually complain about.

9. Common mistakes#

  1. One latency SLO for everything. Meaningless for LLM traffic.
  2. TTFT not bucketed by prompt length. Broken by every long prompt.
  3. No ITL objective. Streaming is the experience.
  4. Availability only. Ignores whether the answers were any good.
  5. Measuring inside the engine. Misses the gateway, the network and the ingress.
  6. Counting 429s as failures. They are the quota doing its job.
  7. Goodput from two separate histograms. Must be decided per request.
  8. Aspirational SLOs. Promise what you have measured you can deliver.
  9. No error-budget policy. Reliability arguments stay political.

10. Hands-on exercise#

  1. Run goodput.go. Change the ITL limit to 60 ms. How much does goodput rise, and which requests changed status?
  2. Write a full SLO, in the format of section 5, for a chat product you know or invent. Justify each threshold from user experience or from a measurement.
  3. Build the latency budget for your TTFT objective. Measure each line on a real or test system. Which line is closest to its share?
  4. Emit per-request ttft_ok and itl_ok from a gateway or from logs, and plot goodput against raw throughput while you raise the load. Where do they diverge?
  5. Design three tiers for one model. For each, state the SLO and its cost: batch size, priority, and whether capacity is reserved.

11. Interview questions#

  1. Why is a single latency SLO wrong for an LLM service?
  2. Write an SLO for a chat service and justify each threshold.
  3. What is goodput, and why must it be computed per request?
  4. Why bucket TTFT by prompt length?
  5. What is an error budget, what is a burn rate, and how would you alert on them?
  6. Should quality be part of the SLO? How would you measure it?
  7. For a reasoning model, what should TTFT measure?
  8. How do service tiers change the infrastructure underneath?

12. Further reading#

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in