Setting SLOs & SLAs
A service level objective (SLO) is a target for an SLI over a time window:
99.9% of valid checkout requests succeed, measured over a rolling 28 days.
└─┬─┘ └───────────── SLI ────────────────┘ └──────────── window ────────────┘
targetA service level agreement (SLA) is a contract: if the provider misses it, the customer gets something back, usually service credits. Availability and SLAs explains the nines and how availability combines across dependencies; this lesson is about choosing and operating the numbers.
SLO, SLA and the internal margin
| SLO | SLA | |
|---|---|---|
| audience | the team and its stakeholders | customers, lawyers |
| consequence of missing it | change of priorities (the error budget policy) | money or credits, reputation |
| who sets it | engineering with product | sales, legal, with engineering's advice |
| typical value | stricter | looser than the SLO, so the team reacts before the contract is breached |
A service with a 99.5% SLA might run to a 99.9% SLO. The gap is a safety margin: by the time the SLO is in danger the team has changed priorities, long before customers can claim credits. Many internal services have SLOs and no SLA at all.
Choosing the target
- Start from what users need, check against what you deliver. Look at the last few months of the SLI. A target you have never met is a wish; one far below your real performance lets reliability decay unnoticed.
- Mind your dependencies. A service that calls a database with a 99.95% SLO can't promise 99.99% without redundancy or graceful degradation.
- Every nine costs roughly ten times more. 99.9% allows about 43 minutes of full outage in 30 days; 99.99% allows about 4. Four minutes is less than one human response time, so 99.99% requires automation that fixes problems without a person.
- Fewer, coarser SLOs. One availability and one latency SLO per critical journey beat fifty per-endpoint SLOs.
- Iterate. Write down the reasoning, review the SLO every quarter, and change it when it doesn't match user happiness (support tickets, churn) in either direction.
Rolling or calendar windows
| Window | Behaviour | Good for |
|---|---|---|
| rolling (last 28 or 30 days) | an incident "counts" for exactly the window length, then drops out | operations: alerting, release decisions; 28 days contains four of each weekday |
| calendar (this month, this quarter) | resets on the 1st; a bad incident on the 30th is forgiven two days later | SLAs, reporting to the business |
The model replays 90 days of daily traffic with two incidents and evaluates a 99.9% SLO both ways:
import random
rng = random.Random(11)
days = []
for d in range(90):
valid = 200_000 + rng.randrange(-20_000, 20_000)
bad = int(valid * rng.uniform(0.0002, 0.0006)) # normal background errors
if d == 25:
bad += 9_000 # about an hour of full outage
if d == 58:
bad += 3_000 # a smaller one
days.append((valid, bad))
def sli(span):
valid = sum(v for v, _ in span)
bad = sum(b for _, b in span)
return 1 - bad / valid
print("day rolling-28d calendar-month (month = 30 days)")
for d in (20, 25, 30, 40, 52, 53, 58, 60, 65, 80, 87):
rolling = sli(days[max(0, d - 27): d + 1])
month_start = d - d % 30
calendar = sli(days[month_start: d + 1])
flag = lambda x: "MISS" if x < 0.999 else "ok"
print(f"{d:>3} {rolling:.4%} {flag(rolling):<4} {calendar:.4%} {flag(calendar)}")day rolling-28d calendar-month (month = 30 days)
20 99.9601% ok 99.9601% ok
25 99.7887% MISS 99.7887% MISS
30 99.7987% MISS 99.9549% ok
40 99.7970% MISS 99.9598% ok
52 99.7996% MISS 99.9624% ok
53 99.9627% ok 99.9630% ok
58 99.9072% ok 99.9090% ok
60 99.9058% ok 99.9552% ok
65 99.9047% ok 99.9533% ok
80 99.9070% ok 99.9634% ok
87 99.9619% ok 99.9619% ok
The big outage on day 25 breaks the SLO in both views. The calendar view forgets it on day 30 when the month resets; the rolling view stays red until the outage leaves the 28-day window on day 53. Neither is wrong, but they answer different questions: "how are we doing right now?" (rolling) versus "did we keep the promise this month?" (calendar). The smaller incident on day 58 spends part of the budget in both views but stays inside the SLO: an SLO is not a promise of zero incidents.
Latency SLOs: thresholds, not averages
Averages hide the slow tail that users complain about. State latency SLOs as a share of requests under a threshold, often two thresholds for one journey:
90% of checkout requests complete in under 300 ms
99% of checkout requests complete in under 1,500 ms (both over a rolling 28 days)Test yourself
Why is an SLA normally looser than the internal SLO for the same service?
- Lawyers prefer round numbers
- So the team reacts to SLO misses well before the contract is breached
- SLAs measure different things
- SLOs are only for latency
In the model, why does the rolling window show the day-25 outage until day 53?
- The outage lasted 28 days
- A rolling 28-day window keeps each day's errors for 28 days
- Calendar months are longer
- Random noise
Your service has delivered 99.95% for six months. Product proposes a 99.99% SLO. What is the first concern?
- None, higher is better
- You have never met it, and four minutes a month leaves no time for a human to respond
- Prometheus can't store four nines
- SLOs must be 99.9%