Sub topic 8
Error budgets: how much a target allows to fail
This chapter assumes you know what an SLI and an SLO are, as covered in the previous chapter. You should also be comfortable with percentages and with the Python used in earlier chapters. An SLO states how good the service should be. The error budget states how much badness that SLO still permits, and a team can use that allowance to make decisions.
What an error budget is
An error budget is the amount of failure that an SLO allows over a time window. It is the complement of the target:
error budget = 1 - SLOA 99.9% SLO means 0.1% of the measured events may be bad. "Bad" is whatever your SLI defines as bad: a failed request, a request slower than a threshold, or a minute in which the service was down.
The budget turns a target into something you can spend. A service with a 99.9% SLO is not expected to be perfect. It is expected to stay within an agreed amount of imperfection. This has two consequences:
- A service running far under its budget is probably more reliable than users need. The team may be shipping too slowly or spending too much on redundancy.
- A service that has spent its budget is less reliable than promised, and reliability work should take priority over new features.
Two ways to count: time and events
The same SLO gives two kinds of budget, and the right one depends on how the SLI is defined.
Time-based budget. The SLI is "is the service up in this minute?". The budget is minutes of allowed unavailability.
# Error budget for a 99.9% availability SLO over 30 days
slo = 0.999
window_minutes = 30 * 24 * 60
error_budget_minutes = window_minutes * (1 - slo)
print(round(error_budget_minutes, 1)) # 43.2Event-based budget. The SLI is "did this request succeed (and finish fast enough)?". The budget is a number of bad requests. This is usually the better choice for request/response systems, because it weights busy periods more heavily than quiet ones. A five-minute outage at peak hurts more users than one at 4 a.m., and a time-based count treats them the same.
slo = 0.999
avg_rps = 500 # average requests per second
window_s = 30 * 24 * 60 * 60 # 30 days in seconds
total_requests = avg_rps * window_s
allowed_bad = round(total_requests * (1 - slo))
print(total_requests) # 1296000000
print(allowed_bad) # 1296000At 500 requests per second on average, a 99.9% SLO allows about 1.3 million failed requests per month. The two views agree only when traffic is flat.
The table shows how the budget shrinks as the target tightens. The figures are for a 30-day window.
| SLO | Error budget | Allowed downtime per 30 days |
|---|---|---|
| 99% | 1% | 432 minutes (7.2 hours) |
| 99.9% | 0.1% | 43.2 minutes |
| 99.95% | 0.05% | 21.6 minutes |
| 99.99% | 0.01% | 4.3 minutes |
At 99.99% the budget is smaller than the time a human needs to be paged, log in and diagnose a problem. Such a target forces automated failover and rollback, and it costs much more to run. Setting it only makes sense if the product needs it.
What counts against the budget
The budget is only as meaningful as the SLI behind it. Decide these points before you start counting.
- Latency violations count. If the SLO says "99% of requests complete within 300 ms", a request that returns correctly in 2 seconds is a bad event. A latency SLO and an availability SLO can share one budget if you define a good event as "succeeded and was fast enough".
- Where you measure matters. Measuring at the load balancer misses requests that never arrived because of DNS or network failures. Measuring at the client sees more of what users experience but adds noise from their networks.
- Excluded events must be agreed in advance. Client errors such as HTTP 400 or 404 usually do not count, because the service behaved correctly. Planned maintenance is a different matter. If users cannot use the service, many teams count it anyway. Whatever you choose, write it down.
- Dependencies spend your budget. If your service calls a database with a 99.9% SLO and a payment provider with 99.9%, and both are required, your best possible availability is about 0.999 × 0.999 ≈ 99.8%. You cannot promise 99.9% on top of them without redundancy, caching or graceful degradation.
dependencies = [0.999, 0.999, 0.9995] # each is required for a request to succeed
combined = 1.0
for availability in dependencies:
combined *= availability
print(round(combined, 4)) # 0.9975This is why the SLO a team can offer is usually lower than the SLOs of the best components it uses.
Tracking consumption
The simplest status check compares bad events so far with the allowance for the window.
def budget_status(slo, total_events, bad_events):
allowed = total_events * (1 - slo)
remaining = allowed - bad_events
consumed = bad_events / allowed
return round(allowed), round(remaining), round(consumed * 100, 1)
allowed, remaining, consumed_pct = budget_status(
slo=0.999, total_events=1_000_000, bad_events=400
)
print(allowed, remaining, consumed_pct) # 1000 600 40.0After one million requests, 400 failures have used 40% of the budget. The numbers become useful when you compare them with how much of the window has passed. Using 40% of the budget in 10% of the window means you are on course to overspend.
Burn rate
Burn rate expresses how fast the budget is being consumed compared with the speed that would use it up exactly at the end of the window.
- A burn rate of 1 means the budget runs out exactly when the window ends.
- A burn rate of 2 means it runs out in half the window.
- A burn rate of 0 means nothing is failing.
def burn_rate(bad, total, slo):
if total == 0:
return 0.0
observed_error_ratio = bad / total
return observed_error_ratio / (1 - slo)
rate = burn_rate(bad=60, total=10_000, slo=0.999)
print(round(rate, 1)) # 6.0
print(round(30 / rate, 1)) # 5.0 days until a 30-day budget is goneHere 0.6% of requests are failing against an allowance of 0.1%, so the budget is burning six times too fast. At that rate a 30-day budget is gone in five days.
Burn rate is a better alert signal than a raw error count, because it scales with the SLO. A 0.5% error rate is a minor issue for a 99% SLO (burn rate 0.5) and an emergency for a 99.99% SLO (burn rate 50).
Alerting on burn rate
An alert on a single threshold either fires too late or fires constantly. A common approach pairs a high burn rate over a short window, which catches sudden outages, with a lower burn rate over a longer window, which catches slow leaks. The values below are widely used starting points for a 30-day window, not fixed rules.
| Burn rate | Alert window | Share of 30-day budget consumed | Typical response |
|---|---|---|---|
| 14.4 | 1 hour | 2% | Page someone now |
| 6 | 6 hours | 5% | Page someone |
| 1 | 3 days | 10% | Open a ticket |
The "share consumed" column is burn rate × window length ÷ 720 hours. For the first row, 14.4 × 1 ÷ 720 = 2%. Many teams also require that a shorter confirmation window (for example, 5 minutes) is still burning, so the alert clears soon after the problem is fixed.
Using the budget to make decisions
An error budget only matters if it changes behavior. The agreement is usually written as a short policy that product and engineering both accept before any incident happens.
Typical policy elements:
- Healthy budget. Release as usual. Run experiments, canary risky changes and accept some failure as the price of speed.
- Low budget. Require extra review for risky changes, delay large migrations and put known reliability fixes at the top of the backlog.
- Exhausted budget. Halt feature releases except for fixes that improve reliability or security. Run a review of what spent the budget.
- Large single events. If one incident consumes more than a set share of the budget (for example 20%), require a written postmortem.
Without the policy, the number is only a dashboard. The value comes from the shared agreement that reliability work wins when the budget is gone.
Choosing the window
The window length changes how the budget behaves.
- Rolling windows (the last 30 days) recover smoothly. An incident drops out of the calculation 30 days later. They are the usual choice for alerting and steady day-to-day decisions.
- Calendar windows (a month or quarter) reset suddenly. They match business reporting and contracts, but they invite risk-taking just after a reset and caution just before the end.
- Short windows (a day or week) react quickly but are noisy. One bad hour can use most of a one-day budget.
- Long windows (a quarter) are stable but hide recent problems.
A 30-day rolling window is a reasonable default. If an SLA contract uses a calendar month, keep the internal SLO stricter than the SLA so that the budget runs out before you owe a refund.
Common mistakes
- Treating the budget as a target to hit. The aim is not to burn it all. Large unused budget over many windows suggests the SLO could be tighter or that the team is being too careful.
- Setting 100%. A 100% SLO has a zero budget, so any change is forbidden. Users cannot tell the difference between 99.99% and 100% when their own network and device fail more often.
- Counting too few events. At low traffic, one failure can look like a large share of the budget. With 1,000 requests a month and a 99.9% SLO, the budget is one failed request. Use a longer window, or a synthetic probe to add measured events.
- Ignoring the shape of failures. Ten minutes of total outage and ten minutes of 1% errors can spend very different amounts of budget, though both feel like "an incident". Event-based counting makes the difference visible.
- Hiding latency failures. If the SLI only counts HTTP errors, a slow but successful service shows a full budget while users leave. Include a latency threshold in the definition of a good event.
- Setting alerts on the SLO instead of the budget. An alert that waits until the SLO is already breached gives no time to react. Burn-rate alerts warn earlier.
Connecting to the rest of the plan
The SLO and its budget sit between the targets you derived earlier and the validation work later in the plan. The percentile and latency-budget chapters supply the thresholds that define a good event. The later chapters on fan-out and load tests explain why real services often burn budget faster than component numbers suggest, and how measurement should lead you to revise targets that turn out to be unrealistic.
Exercise
A checkout API has a 99.95% availability SLO over a rolling 30 days and serves an average of 200 requests per second. (a) How many failed requests does the event-based budget allow in the window? (b) In the last hour, 1,200 of 720,000 requests failed. What is the burn rate, and how long until the 30-day budget is exhausted at that rate?
Show answer
(a) Total requests = 200 × 30 × 24 × 60 × 60 = 200 × 2,592,000 = 518,400,000. The budget is 0.05% of that, which is 259,200 failed requests. (b) The error ratio is 1,200 / 720,000 = 0.00167 (about 0.167%). The allowed ratio is 0.0005. The burn rate is 0.00167 / 0.0005 ≈ 3.3. At that rate the 30-day budget lasts about 30 / 3.3 ≈ 9 days. This is above 1, so it needs attention, but it is below the 6 and 14.4 thresholds in the example alert table. It would produce a ticket and not a page.
Exercise
Your service depends on two required services that each have a 99.9% availability SLO, and your own code fails 0.05% of requests. Can you promise a 99.9% SLO to your users without any redundancy or fallback? Explain with numbers.
Show answer
No. If failures are independent, availability is about 0.999 × 0.999 × 0.9995 ≈ 0.9975, which is 99.75%. The implied error rate is about 0.25%, which is more than twice the 0.1% budget a 99.9% SLO allows. To promise 99.9% you would need redundancy, caching or graceful degradation for the dependencies, or a lower SLO of roughly 99.5%, which leaves some margin.
Exercise
Why is an event-based error budget usually a better fit than a time-based one for a request/response API with strong daily peaks?
Show answer
A time-based budget counts every minute of failure equally. An event-based budget counts failed requests, so an outage during peak traffic consumes more budget than the same outage at night. This matches the number of users affected. It also lets the SLI include latency thresholds in the same unit as availability.