Reliability and Cost Engineering › Service Objectives and the Error Budget

Michael BrenndoerferDecember 2, 20264 min read
Language AI HandbookAll chapters
Part 64 of 67Compound AI System Design
Chapter 490Reliability and Cost Engineering › Service Objectives and the Error Budget
Reading section 3 of 12 · Service Objectives and the Error Budget · 4 minSection 3 of 12 · 4 min

Section 3 of 12 · 4 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

For a single service, model latency TT in seconds and let SS equal one on success and zero on failure. The SLI counts successful requests that meet the deadline.

SLI=#{r:Sr=1 and Tr≤θ}#{r}\text{SLI} = \frac{\#\{r : S_r = 1 \text{ and } T_r \le \theta\}}{\#\{r\}}

Here rr ranges over eligible requests in the measurement window. SrS_r records success, TrT_r is end-to-end latency in seconds, and θ\theta is the deadline in seconds. A failure or a late success uses one bad event. The ratio is undefined when there are no eligible requests. With NN requests and target qq, the SLI meets the objective when SLI≥q\text{SLI} \ge q. Equivalently, at most ⌊(1−q)N⌋\lfloor(1-q)N\rfloor requests may be bad. The fixture stores the target as an exact fraction and takes the integer part of the nonnegative allowance.

The bad-event count lets you compare an incident with the window's allowance. A retry uses the error budget only if the logical request ultimately fails the SLI. A fast fallback counts as good only when it meets both the deadline and the service's success criteria, which may include a quality requirement.

A latency median alone describes the middle request and leaves the slower tail unspecified. Measure the fraction meeting the deadline and use request traces to find which calls and queues contributed to the misses.

The seeded example uses a lognormal latency distribution and independently assigns a failure flag to each request. These are illustrative assumptions.

PythonIn [3]
CollapseExpand
import numpy as np

rng = np.random.default_rng(7)

# Single service: 20,000 requests, lognormal latency in seconds.
N = 20_000
mu_log, sigma_log = np.log(0.4), 0.6  # median 0.4s
latency = rng.lognormal(mu_log, sigma_log, size=N)

# Independent per-request failure hazard (timeouts, 5xx, parse errors).
P_FAIL = 0.004
success = rng.random(N) >= P_FAIL

TAU = 2.0  # latency threshold in seconds

If the logarithm of latency has mean μ=ln⁡(0.4)\mu=\ln(0.4) and standard deviation σ=0.6\sigma=0.6, the lognormal median is eμ=0.4e^\mu=0.4 seconds. Its mean is eμ+σ2/2≈0.48e^{\mu+\sigma^2/2}\approx0.48 seconds. Increasing σ\sigma at fixed μ\mu spreads the distribution while leaving its median unchanged.

Now compute the SLI, the error budget, and the percentile structure.

ConsoleOut [4]
CollapseExpand
Observed SLI (success & <= 2.0s): 0.9932
SLO target:                        0.9950
Error budget (fraction):           0.0050  -> 100 reqs / window
Bad requests observed:             135
Budget remaining:                  -35 reqs

p50   : 0.397s
p90   : 0.854s
p95   : 1.064s
p99   : 1.591s
p99.9 : 2.446s

The histogram shows the deadline against the latency distribution. It does not show which requests failed independently of latency.

PythonIn [5]
CollapseExpand
lat_mean = float(latency.mean())
lat_p99 = float(np.percentile(latency, 99))
hist_edges = np.geomspace(latency.min(), latency.max(), 50)
hist_counts, _ = np.histogram(latency, bins=hist_edges)
hist_widths = np.diff(hist_edges)
VisualizationOut [6]
CollapseExpand
A latency histogram on a logarithmic x-axis with mean and 99th percentile to the left of the two-second deadline.
Simulated request counts in equal intervals of log latency. The dashed line marks the two-second deadline. Requests to its right are late. The SLI also counts failures, including any left of the line.

The 99.5% SLO allows 100 bad requests in this 20,000-request window. Compare that allowance with the bad count. The mean is under half a second, and some requests still miss the two-second deadline. The percentiles show how far the tail extends.

The measurement boundary problem

Specify where the clock starts and stops. For this example, success means a complete usable response by the deadline, with errors and timeouts in the eligible request denominator. Time to first token is a separate measure for streaming. Check what any provider timing includes. Your end-to-end clock can include queueing even when you cannot break out its provider-side share.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy