Course contents · Lesson 18 of 22

SLI, SLO and SLA Explained with a Pizza Promise

Alerts, Dashboards and SLOs · Lesson 18 of 22 · 9 min Engineer

Your team has just launched a checkout service, and your manager asks two questions: "How reliable is it?" and "How reliable does it need to be?" Saying "it is up most of the time" will not do. Engineers answer with three related terms, the SLI, SLO and SLA: a measurement, a goal and a contract. This lesson defines each one exactly, then shows the number that ties them together, the error budget, and how teams use it to decide when to ship and when to stop.

SLI: what you measure

A service level indicator (SLI) is a number that says how well your service is treating its users. The most useful form is a ratio: good events divided by total events. Multiply by 100 and you get a percentage, where 100% means every event went well. An event is usually one request, but it can be one login, one file upload or one background job.

The two most common SLIs are availability and latency. An availability SLI counts requests that did not fail with a server error (an HTTP status in the 500s) and divides by all requests. A latency SLI counts requests answered in 300 milliseconds or less and divides by all requests. A 404 for a mistyped address normally counts as good, because the service answered correctly and the mistake was the caller's.

If your service exposes a request-duration histogram, which you met in Counters, Gauges and Histograms, Prometheus can compute the latency SLI for the last 30 days with this query:

sum(increase(http_request_duration_seconds_bucket{job="checkout",le="0.3"}[30d]))
/
sum(increase(http_request_duration_seconds_count{job="checkout"}[30d]))

The _bucket{le="0.3"} series counts requests that took at most 0.3 seconds, and _count counts all of them, so the result is one number such as 0.99942: 99.942% of requests were fast enough. This only works if the histogram has a bucket boundary at exactly 0.3, and the default buckets of most Prometheus client libraries jump from 0.25 to 0.5. Measure as close to the user as you can, for example at the load balancer, because a crashed server cannot count its own failures.

SLO: the target over a time window

A service level objective (SLO) is a target for an SLI over a stated time window. "99.9% of checkout requests succeed, measured over a rolling 30 days" is a complete SLO. It names the SLI (successful checkout requests), the target (99.9%) and the window (30 days). Leave out any of the three and nobody can tell whether you met it.

The window can be rolling or calendar. A rolling 30-day window always looks at the most recent 30 days, so a bad hour counts against you for exactly 30 days and then drops out. A calendar window, such as each month, resets on the 1st. Rolling windows match how users remember you; calendar windows match how contracts and bills are written.

Do not set the target at 100%. As the uptime lesson showed, each extra nine costs far more than the last, and users cannot tell 99.99% from 100% because their own Wi-Fi and phones fail more often than that. Choose the target from what users need, then check it against what the service has actually achieved in recent months.

SLA: the contract with a penalty

A service level agreement (SLA) is a contract between a provider and its customers. It names a target and says what happens when the provider misses it, usually a service credit (a discount on the next bill) or a refund. An SLA is a business and legal document: engineers supply the numbers, and lawyers and sales teams write the rest.

An SLA target is almost always looser than the internal SLO. A team might aim for 99.9% internally while the contract promises 99.5%, with a 10% credit below that. The gap is a safety margin: you notice and fix a missed SLO long before you owe anyone money. Many internal services have SLOs and no SLA at all, because there is no paying customer, yet the SLO still guides the work.

Three stacked layers: the SLI is the measurement, the SLO adds a target and a window, the SLA adds a penalty in a contract, each with a pizza and a web-service example
Each layer builds on the one above it: an SLO is an SLI plus a target and a window, and an SLA adds a penalty for missing a target.

The error budget: how much failure you can afford

The error budget is 100% minus the SLO. A 99.9% SLO allows 0.1% of events to be bad. Counted in requests, that is simple: if checkout serves 10 million requests in 30 days, up to 10,000 of them may fail before you miss the target.

Counted in time, 30 days is 30 × 24 × 60 = 43,200 minutes, and 0.1% of that is 43.2 minutes. That is how long a full outage, with every request failing, can last before the SLO is broken. A partial outage spends the budget more slowly: 40 minutes with half of requests failing uses 20 minutes' worth, assuming traffic is steady.

A 30-day timeline with two incidents and a 43.2-minute budget bar: incident A spent 12 minutes, incident B spent 20 minutes, 11.2 minutes are left
A 40-minute half outage costs more budget than a 12-minute full one, because the budget counts failed requests, not minutes of alarm.

Burn rate is how fast you are spending the budget compared with the even pace that would use it up exactly at the end of the window. It is the observed error ratio divided by the allowed error ratio. With a 99.9% SLO, an error ratio of 0.1% is a burn rate of 1; an error ratio of 1% is a burn rate of 10, which empties a 30-day budget in 3 days. Burn rate is what good SLO alerts watch, as the next lesson shows.

Spending the budget on purpose

The budget turns an argument ("is it reliable enough?") into a number that product managers and engineers both accept. While budget remains, the team ships features, runs experiments and makes planned risky changes, such as a database migration. When the budget is spent, the team freezes feature releases and works on reliability until the SLI is back above target.

Write those rules down in advance as an error budget policy, agreed while things are calm, so nobody argues about them during an outage. A typical policy says two things. If the rolling 30-day budget is spent, only fixes and reliability work ship. And any single incident that uses more than 20% of the budget gets a written postmortem, a blameless review of what happened and why.

Flowchart: measure the SLI as good divided by total events, check whether error budget is left, keep shipping if yes, freeze features if no, then check again the next day
The same daily check drives both outcomes, so the release pace follows the data instead of whoever argues loudest.

An untouched budget is a signal too. If you finish every month with nearly all of it left, the SLO may be looser than users need, or the team may be moving more cautiously than it has to. The budget exists to be spent on change.

Check yourself

Your SLO is 99.9% of requests over 30 days and the service handles 2 million requests in that time. How many may fail?

2,000, because the error budget is 0.1% of all requests and 0.1% of 2,000,000 is 2,000.

Why is the SLA target usually lower than the SLO?

The gap is a safety margin: the team sees and fixes a missed SLO before the company owes customers credits.

With a 99.9% SLO, the error ratio has been 0.5% all day. What is the burn rate, and how long would a full 30-day budget last at that pace?

The burn rate is 5 (0.5% ÷ 0.1%), so a full budget would last 30 ÷ 5 = 6 days.