Sub topic 7
Error budgets in practice
This chapter assumes you know the difference between an SLI, an SLO and an SLA. It also assumes you can convert an availability target into allowed downtime, as covered in the earlier chapters. Here you will turn an SLO into a budget you can spend, track how fast you spend it, and use it to make release decisions.
What an error budget is
An error budget is the amount of unreliability your SLO permits over a window. If the SLO is 99.9% of requests succeeding over 30 days, then 0.1% of requests may fail. That 0.1% is the budget.
The budget has two uses:
- It sets a limit. Once you have spent it, you have broken the SLO.
- It gives you permission. While budget remains, failures from deployments, experiments, and migrations are acceptable, because the SLO already allows for them.
Without a budget, "should we ship this risky change?" turns into an argument between people who want features and people who want stability. With a budget, the question becomes "how much budget is left, and how much will this change likely cost?"
Computing the budget
For a request-based SLI, the budget is a count of failed requests. This function is the same as the one from the topic plan:
def error_budget_remaining(slo, total_requests, failed_requests):
allowed_failures = (1 - slo) * total_requests
return allowed_failures - failed_requests
print(error_budget_remaining(0.999, 10_000_000, 4_000)) # about 6000 failures leftWith 10 million requests in the window, a 99.9% SLO allows 10,000 failures. Four thousand have happened, so about 6,000 remain. A negative result means the SLO is already missed for this window.
For a time-based SLI, the budget is minutes of downtime. A 99.9% SLO over 30 days gives 43.2 minutes. The arithmetic is the same, with minutes in place of requests.
Budget as a fraction
Teams usually track the budget as a percentage consumed, because it is easy to compare across services. Here, 4,000 failures against a budget of 10,000 means 40% consumed and 60% remaining. A dashboard that shows one number, "budget remaining," is easier to act on than one that shows raw error counts.
The window matters
You must choose how the window works before you can say how much budget is left.
| Window type | How it works | Strength | Weakness |
|---|---|---|---|
| Calendar | Resets on a fixed date, such as the first of the month | Matches reporting and SLA periods | A bad outage on day 2 leaves 28 days of a spent budget, and a reset on day 1 can encourage risky releases |
| Rolling | Always covers the last N days | Reflects recent user experience, with no cliff at reset | An old incident slowly "ages out," so the budget recovers gradually and is harder to explain |
A rolling 28-day or 30-day window is a common default for internal SLOs. Use a calendar window when a contract defines the SLA period that way. A 28-day window has an advantage: it always contains exactly four weeks, so weekly traffic patterns are weighted equally.
Burn rate
Remaining budget tells you where you are. It does not tell you how fast you are moving. Burn rate measures speed:
burn rate = observed error rate / allowed error rate
A burn rate of 1 means you would spend exactly the whole budget by the end of the window. A burn rate of 10 means you would spend it in one tenth of the window.
def burn_rate(slo, error_rate):
return error_rate / (1 - slo)
def hours_to_exhaust(slo, error_rate, window_days=30):
rate = burn_rate(slo, error_rate)
if rate == 0:
return float("inf")
return window_days * 24 / rate
print(round(burn_rate(0.999, 0.01), 2)) # 10.0
print(round(hours_to_exhaust(0.999, 0.01), 1)) # 72.0A 1% error rate sounds small. Against a 99.9% SLO it is a burn rate of 10, and the whole month's budget is gone in 72 hours.
Alerting on burn rate
Alerting on "error rate above X" is noisy, because short spikes that barely touch the budget wake people up. Alerting on burn rate ties the alert to what you care about, which is how much budget the problem will consume. A commonly used scheme from Google's SRE Workbook pairs a burn rate with a time window:
| Burn rate | Long window | Budget consumed in that window | Action |
|---|---|---|---|
| 14.4 | 1 hour | 2% | Page |
| 6 | 6 hours | 5% | Page |
| 1 | 3 days | 10% | Ticket |
You can check one row. At a burn rate of 14.4 for 1 hour in a 30-day (720-hour) window, the consumed fraction is 14.4 × 1 / 720 = 2%.
Each page-level alert is usually paired with a short window, such as 5 minutes. The alert fires only when both windows exceed the threshold. The long window shows the problem is significant. The short window shows it is still happening, so the alert clears soon after the problem is fixed.
def should_page(slo, error_rate_1h, error_rate_5m, threshold=14.4):
limit = threshold * (1 - slo)
return error_rate_1h > limit and error_rate_5m > limit
print(should_page(0.999, 0.02, 0.03)) # True: both windows above 1.44%
print(should_page(0.999, 0.02, 0.001)) # False: the problem has already stoppedThe diagram shows how the signals combine into a decision.
Using the budget to make decisions
A budget only helps if the team agrees in advance what happens at each level. Write this down as an error budget policy. A typical policy covers three states:
- Budget healthy. Ship normally. Run experiments and do risky migrations. If the budget is almost never used, the SLO may be too loose, or the team may be too cautious.
- Budget low or burning fast. Slow down. Require extra review and smaller, more reversible releases. Direct attention to the biggest source of failures.
- Budget exhausted. Freeze changes that are not reliability fixes or security patches until the budget recovers or the owners agree on an exception.
The agreement must include the product owner, not only engineers. A freeze that product management does not accept will not hold.
Learning from where the budget went
Categorize every use of budget: bad deploys, dependency failures, capacity problems, and expected maintenance. After a few months you will see where most of it goes. If 70% of the burn comes from deployments, better rollouts will gain more than adding hardware.
Edge cases and common errors
- Low traffic. A service with 1,000 requests a month and a 99.9% SLO may fail one request in the whole window. The budget is one failure, so a single error is a huge fraction of it. Use a longer window, aggregate similar services, or add synthetic probes to generate steady traffic.
- Counting bad requests. Client errors such as HTTP 404 or 400 usually do not count as failures, because the service worked correctly. Server errors (5xx) and timeouts do. Decide this explicitly. If clients can trigger failures with valid requests, count them.
- Slow successes. A response that arrives after 30 seconds is a failure for the user, even with a 200 status. Include a latency threshold in the SLI, or the budget will look healthy while users suffer.
- A single huge outage. A 40-minute outage can use a whole 43-minute budget in one event. The budget is a number, not a promise that failures are spread evenly. Burn-rate alerts exist to catch this early.
- Dependencies. If your service fails because a dependency failed, users still see an outage. Count it against your budget. Then use the series calculation from earlier chapters to see whether your SLO is even reachable given your dependencies.
- Planned maintenance. Decide in advance whether planned downtime counts. For an internal SLO, count it, since users are affected either way. A contractual SLA may exclude it explicitly.
- SLO versus SLA. Keep the internal SLO stricter than the SLA. The SLO budget then runs out and triggers action before the SLA is breached and credits are owed.
Putting it together
Here is a worked case. A checkout API has a 99.95% SLO over a rolling 30 days and serves about 20 million requests in that window.
- The budget is (1 − 0.9995) × 20,000,000 = 10,000 failed requests.
- A bad deploy causes a 2% error rate for 30 minutes. At about 27,800 requests per minute (20,000,000 / 43,200), that is roughly 833,000 requests and 16,700 failures. That is more than the whole 10,000-failure budget in half an hour.
- The burn rate during the incident is 0.02 / 0.0005 = 40, far above the 14.4 paging threshold, so the on-call engineer is paged within minutes.
Two lessons follow. A short incident can empty a tight budget, which is why high-availability targets need fast detection and rollback. And the policy now applies: the team pauses non-essential releases until the rolling window recovers or the owners decide otherwise.
Exercise
A service has a 99.9% SLO over a 30-day window and handles 50,000,000 requests in that window. So far there have been 18,000 failed requests. (a) How many failures remain in the budget? (b) If the error rate is now steady at 0.5%, what is the burn rate, and how many hours would a full 30-day budget last at that rate?
Show answer
(a) The allowed failures are (1 − 0.999) × 50,000,000 = 50,000. Subtracting the 18,000 already used leaves about 32,000 failures. (b) The burn rate is 0.005 / 0.001 = 5. A full 30-day (720-hour) budget lasts 720 / 5 = 144 hours, or 6 days, at that rate.
Exercise
Your team's 3-day burn rate is 1, but the budget is 85% consumed with 10 days left in the window. A colleague says there is no problem because burn rate 1 means "on track." What is wrong with that argument, and what would you do?
Show answer
A burn rate of 1 means you would spend exactly the whole budget over a full window, but only 15% of the budget remains and 10 of 30 days are left. At the current rate, 10 days would consume about 33% of the budget, which is more than the 15% left, so the SLO will be missed. The burn rate should be compared with the remaining budget and remaining time, not just with 1. Apply the policy for a low budget: slow risky releases, find the main source of errors, and fix it, so that the rate drops below about 0.45 (15% of the budget over 10 days).