SRE: SLOs and error budgets
About this lesson
Site reliability engineering (SRE) does not chase 100%. It measures what users feel with an SLI, sets a target for it with an SLO, and treats the gap, 1 − SLO, as an error budget the team may spend. Follow one service through a 30-day window: 99.9% leaves 1,000 failed requests to spend, a bad release burns them 14.4 times too fast and pages the on-call engineer, and when the budget hits zero an agreed policy freezes feature releases.
Why not 100%?
Site reliability engineering (SRE) runs services the way software engineers would. Its first lesson: 100% reliable is the wrong target. A user on a 99% reliable phone cannot tell 99.99% from 99.999%, and each extra nine costs far more.
users feel the weakest link: phone, Wi-Fi, mobile network, your service 99.9% one nine more 99.99% 99.999% each extra nine can cost ~100x more (SRE book) so: choose a target on purpose
Read the lesson step by step
Why not 100%?
Site reliability engineering (SRE) runs services the way software engineers would. Its first lesson: 100% reliable is the wrong target. A user on a 99% reliable phone cannot tell 99.99% from 99.999%, and each extra nine costs far more.
users feel the weakest link: phone, Wi-Fi, mobile network, your service 99.9% one nine more 99.99% 99.999% each extra nine can cost ~100x more (SRE book) so: choose a target on purposeSLI: count the good
A service level indicator (SLI) measures what users feel: good events divided by all events. Here a request is good if it is answered correctly and fast enough. The counter keeps that running share.
SLI = good events / all events good request: right answer (not HTTP 5xx) and fast enough (say < 300 ms) total, bad = 200_000, 600 sli = 1 - bad / total # 0.997 on day 6SLO: set the target
A service level objective (SLO) is a target for an SLI over a time window. Ours: 99.9% of requests good over a rolling 30 days. An SLA is a contract with penalties, usually looser than the SLO.
slo = 0.999 # SLO: 99.9% good window: the last 30 days, rolling SLI what you measure 99.7% SLO what you aim for 99.9% SLA what you promise, with penalties (usually looser than the SLO)The error budget
The error budget is 1 − SLO: the failures you may have. 0.1% of the 1,000,000 requests expected in 30 days is 1,000 bad requests, ten blocks of 100. In time, it is 43.2 minutes of full outage.
error budget = 1 - SLO = 0.1% budget = round(1e6 * (1 - slo)) # 1000 in time: 30 d x 24 h x 60 min x 0.001 = 43.2 minutes down per 30 days a budget is for spending: releases, experimentsBurning on pace
Days 1 to 3: normal releases, 100 failed requests. 10% of the budget is gone after 10% of the window. That ratio is the burn rate. At 1.0 the budget lasts exactly 30 days, so the team keeps shipping.
day 3 of 30 100 bad of 100,000 burn rate = budget used / window used = 10% / 10% = 1.0 1.0 -> the budget ends with the window SLI so far 99.90%: right on targetA bad release pages
Day 4: a release passes the open gate and breaks checkout. In one hour 2% of the budget burns, a burn rate of 14.4. Google's SRE workbook suggests paging at exactly this point: an urgent alert wakes the on-call engineer now.
day 4, first hour: 20 bad of ~1,389 error rate 1.44% / 0.1% allowed = 14.4 14.4 for 1 h = 2% of the budget SRE workbook, alerting on SLOs: 2% in 1 h (14.4) page 5% in 6 h (6) page 10% in 3 d (1) ticketBurn rate 3
By day 6, 600 requests have failed: 60% of the budget in 20% of the window, a burn rate of 3.0. That equals the error rate, 0.3%, over the 0.1% allowed. At 3× a 30-day budget lasts 10 days.
day 6 of 30 600 bad of 200,000 left = budget - bad # 400 burn = round((1 - sli) / (1 - slo), 1) # 3.0 60% / 20% = 0.3% / 0.1% = 3.0 budget lasts 30 / 3 = 10 daysBudget spent: freeze
Days 7 to 10: the fix is slow and failures continue at 3×. On day 10 the budget hits zero, as predicted. The team's error budget policy kicks in: feature releases stop until the service is back within its SLO.
day 10 of 30 1,000 bad of 333,333 budget left: 0 error budget policy (SRE workbook): halt changes and releases except urgent fixes and security fixes until the service is back within its SLOOne number, shared
Fixes and security patches still pass the gate. Product, developers and SREs agreed this policy in advance, so no one argues mid-incident. One shared number decides: budget left, ship faster; budget gone, work on reliability.
fix -> passes the gate, errors stop feature -> waits policy agreed before any incident by product, developers and SREs budget left -> ship faster, take risks budget gone -> spend time on reliability
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01A service has an SLO of 99.9% of requests good over 30 days and expects 2,000,000 requests. What is its error budget?
The error budget is 1 − SLO = 0.1%, and 0.1% of 2,000,000 is 2,000 failed requests.
02Which one is a contract with consequences, such as a refund, if it is missed?
An SLA (service level agreement) is a promise to customers with penalties. The SLO is the team's own target, usually stricter than the SLA so the team is warned first.
03On day 15 of a 30-day window, 75% of the error budget is gone. What is the burn rate so far?
Burn rate = budget used ÷ window used = 75% ÷ 50% = 1.5. At that pace the budget runs out on day 20, ten days early.
04Why does Google's SRE workbook page on a burn rate of 14.4 over one hour, instead of on every failed request?
A few errors are expected and fit in the budget. Burning 2% of the month's budget in one hour is an emergency; slower burns, such as 10% in 3 days, only open a ticket.
05The error budget is used up. What does a typical error budget policy say?
The SRE workbook's example policy halts changes and releases except urgent fixes and security fixes until the service is back within its SLO.
Glossary
- Site reliability engineering (SRE)
- Running production services with software-engineering methods, started at Google. It sets reliability targets on purpose and automates operations work.
- SLI (service level indicator)
- A measure of the service users get, usually good events divided by all events, such as the share of requests answered correctly and fast enough.
- SLO (service level objective)
- A target for an SLI over a time window, for example 99.9% of requests good over 30 days.
- SLA (service level agreement)
- A contract with users that includes consequences, such as refunds, if its SLOs are missed. Usually looser than the internal SLO.
- Error budget
- 1 − SLO: the amount of failure allowed in the window. At 99.9% it is 0.1% of requests, or 43.2 minutes of full outage in 30 days.
- Burn rate
- How fast the error budget is being used, compared with an even pace. 1 uses it up exactly at the end of the window; 3 uses it up in a third of the time.
- Page
- An urgent alert that calls the on-call engineer straight away, as opposed to a ticket that can wait for working hours.
- Error budget policy
- Rules agreed in advance for what happens when the budget runs out, typically a freeze on feature releases.
Notes and sources
- The 99% phone and the 100x cost per extra nine are from the Google SRE book, chapter 3 (Embracing Risk).
- An SLA (service level agreement) is a contract with consequences, such as a refund, if its SLOs are missed. Google sets the SLO in an SLA looser than its internal SLO, so the team is warned before the contract is broken.
- The SRE workbook suggests a four-week rolling window; this lesson uses 30 days. In a rolling window old failures keep counting until they slide out of it, so a budget refills slowly.
- With a request-based SLO the budget is 0.1% of the requests that actually arrive. The example assumes steady traffic of 1,000,000 requests per 30 days (about 1,389 an hour).
- Burn rate 1 uses the budget up exactly at the end of the window. The SRE workbook pages on 2% of the budget in 1 hour (14.4) or 5% in 6 hours (6), and opens a ticket for 10% in 3 days (1). It also checks a short window, so alerts stop soon after a fix.
- The request tokens are symbolic: real error rates here are 0.1% to 1.44%, far fewer failures than the tokens show.
- In the cloud: Google Cloud Monitoring defines SLOs and burn-rate alerts, AWS CloudWatch Application Signals defines SLOs, and on Azure you can build the same burn-rate alerts with Azure Monitor alert rules.
- The code card is real Python 3. round() hides floating point noise: 1 - 0.999 is not exactly 0.001. Add print(sli, budget, left, burn) and it prints 0.997 1000 400 3.0.
- Google SRE book, ch. 3: Embracing Risk
- Google SRE book, ch. 4: Service Level Objectives
- Google SRE workbook, ch. 2: Implementing SLOs
- Google SRE workbook, ch. 5: Alerting on SLOs
- Google SRE workbook: Example Error Budget Policy
- Google Cloud blog: SRE fundamentals, SLIs, SLAs and SLOs
- Google Cloud Monitoring: SLO monitoring
- Google Cloud Monitoring: Alerting on your burn rate
- Amazon CloudWatch: Service level objectives (SLOs)
- Azure Monitor: Alerts overview
- Python docs: round()
Quiz Unlocks after the last step.