14 / 16 · Reliability
SLOs, error budgets and alerting
Define reliable answer saving, count failures with the right denominator, and test two alert windows on a reproducible traffic trace.
On this page 7
A learner submits an answer. The interface may show “saved” only after the storage service acknowledges the write. A response that arrives too late leaves the learner unsure whether to retry. The observability note supplied measurements; here we turn this particular user journey into an objective and a response policy, then test that policy on invented traffic.
The experiment separates three questions: how many attempts were bad, whether the whole reporting period meets its target, and whether a current incident needs attention. A good period total can coexist with a short incident that should be stopped immediately.
SLI, SLO and SLA#
For this service, an eligible attempt is an authenticated, well-formed request to save an answer. Retries count as separate attempts: this measures the experience of attempting a save, not the fraction of unique answers eventually stored. Invalid requests are excluded by an explicit classification rule, rather than whenever an exclusion improves the score.
A good attempt receives a durable acknowledgement within 800 ms. A timeout, a server error or a later acknowledgement is bad, counted once even if several conditions apply. A gateway records both the denominator and the outcome. Client-to-gateway failures need a separate client measurement; this indicator cannot see them.
For an interval containing eligible attempts and bad ones, the service level indicator is
Our service level objective is : at least 99.5% good attempts over the preceding 14 days. This value is a stated design choice for the fictional service, not a recommended threshold for every product. An SLA adds contractual commitments and remedies; an internal SLO does not itself create a compensation contract. These distinctions and the use of objectives to make reliability decisions are established SRE concepts. Beyer et al., 2016, ch. 4
A request ratio needs the request count as its weight. In twelve minutes, suppose eleven minutes contain 100 successful attempts each and the remaining minute contains one failed attempt. The failure fraction is . Averaging the twelve minute percentages instead gives . The quiet minute has acquired the same weight as a minute with a hundred requests.
A request and a minute have different weights
| Interval | Attempts | Bad attempts |
|---|---|---|
| 11 ordinary minutes | 1100 | 0 |
| 1 quiet minute | 1 | 1 |
- Fraction of failed requests
- 1 / 1101 = 0.091%
- Mean of minute fractions
- 100% / 12 = 8.333%
With no eligible requests the ratio is undefined. Report insufficient observations; do not manufacture 100% success. A separate probe can still test whether the service is reachable.
Availability arithmetic#
Nines into minutes#
The unit of the objective determines the budget. For a time-based objective, allowed downtime is . Over 14 days there are 20,160 minutes: 99% permits 201.6 minutes, 99.5% permits 100.8, and 99.9% permits 20.16. Each additional nine reduces the permitted fraction by ten.
Our answer-saving objective is request-based. Its budget is bad attempts, not 100.8 minutes of downtime. An outage during a busy lesson and one at night can last equally long but affect very different numbers of attempts.
Dependencies in series#
Suppose saving requires both a gateway with availability 0.998 and a storage service with availability 0.999. Under independence, both work with probability
This is a model of their joint working state, not a prediction of the observed request SLI. It omits latency, failures before the gateway and traffic dependence. For small failure probabilities , expanding the product gives .
Redundancy in parallel#
If either of two independent gateway replicas suffices, both fail with probability , so their joint availability is . In general,
Now add a shared routing failure with probability 0.001, independent of the replica failures. The pair works only when routing works, giving . A common dependency dominates the apparently excellent replica pair. The formulas follow from independent events; a shared deployment or region failure must be represented explicitly, not hidden inside an independence assumption.
The error budget and its policy#
For a measured interval, the allowed count is and the fraction used is . The allowance need not be an integer: meeting the objective means the integer count is no greater than . A rolling window recalculates both counts as old observations leave it; it is not a purse that refills only at midnight.
The following policy is specified for this example’s answer-saving workflow:
- Before a deployment, the owner checks the current failure indicator, the recent acknowledgement delays and whether its rollback still works. Missing telemetry prevents an unattended rollout.
- During an incident, urgent failures go to the on-call operator with the recent release identifier. The first decision is whether to roll back or restrict new writes while retaining the learner’s unsaved answer locally. The SLO score does not authorize silently losing answers.
- A persistent moderate problem creates one tracked investigation. The owner checks queue delay and storage latency before changing an alert threshold. Repeated notifications update the same incident.
- At the next release review, the owner compares the 14-day budget and unresolved incidents with the proposed change. A failed objective requires an explicit mitigation and recorded release decision; this example does not prescribe a universal company-wide release freeze.
The policy states responsibilities and actions. The numeric rules below are a detector for it; they do not replace the operator or the product decision.
Burn rate#
Let be the observed failure fraction. Its burn rate relative to the objective is
With , 5% failures is burn rate 10 and 1% failures is burn rate 2. If these rates persisted across a workload of the same size, they would consume ten or two times the allowed failures. Burn rate is a useful normalization; the underlying idea of budget-based alerting is described by Thurgood et al., 2018.
For a short window with requests inside a reporting period with requests, its share of the period’s budget is exactly
Only under constant request rate does this become . With changing traffic, replacing request share by time share can misstate the cost of an incident. The experiment below keeps integer counts to avoid that substitution.
Multi-window, multi-burn-rate alerts#
We choose two detector settings for this fictional service. The urgent setting asks whether a sizeable share of saves is failing across a lesson-length slice; the slower setting looks for acknowledgement delays that persist beyond a short fluctuation.
| Response | Long window | Recent window | Failure fraction in both | Minimum attempts in long window |
|---|---|---|---|---|
| Page | 12 min | 3 min | at least 5% | 900 |
| Investigation ticket | 180 min | 30 min | at least 1% | 600 |
These are experiment inputs, selected independently for the answer-save scenario. They are not a standard alert table. The two fractions correspond to burn rates 10 and 2. The recent window checks whether failures are still occurring; the long window keeps one short spike from deciding everything. The volume floor is a separate condition, not a statistical guarantee.
At the end of each complete minute, compute both ratios from sums of counts. Fire only when both ratios and the volume condition pass. Use >= at the threshold and no extra waiting interval in this reference implementation. A dashboard can show the same counts, so an operator can reconstruct why a rule fired.
Checking them on numbers#
The reference script constructs 14 days without downloading data. There are 1,000 attempts per minute from 08:00 up to 18:00 and 100 per minute otherwise. Normally all are good. Three disturbances are inserted; day numbers start at zero, and a timestamp is the end of the last complete minute bucket.
| Disturbance | Inserted observations | Result of the detector |
|---|---|---|
| Quiet minute, day 2 at 03:00 | One attempt, and it is bad; replaces that minute’s 100 attempts | Neither condition fires. |
| Failed deployment, day 4 from 11:10 to 11:22 | 200 bad out of 1,000 attempts every minute | Page first fires at 11:13, last remains active at 11:24, and is clear at 11:25. |
| Slow acknowledgements, day 9 at 23:00 for 180 min | Three bad out of 100 attempts every minute | No page; ticket first fires on day 10 at 00:00, after 60 min. |
At 11:13 the page’s long window contains 600 bad saves out of 12,000 attempts, exactly 5%; its three recent buckets are all at 20%. After rollback, the last remaining failing bucket in the short window keeps it above 5% at 11:24. At 11:25 all three recent buckets are healthy.
The deployment also activates the raw ticket condition from 11:19 to 11:50. Those are observations of the same incident, not evidence for another notification. The slow incident activates it from day 10 at 00:00 through 02:20. The script reports raw conditions; routing and deduplication are separate.
Across the whole fixture there are 9,575,901 attempts and 2,941 bad attempts. The SLI is 99.969287%, and 6.142503% of the available request budget is used. The 14-day SLO is met despite both substantive incidents. Waiting for the period’s objective to fail would miss the point of early detection.
Alert fatigue and paging#
For the failed deployment, one incident should collect the page, its later ticket condition and diagnostic signals. Record when the operator acknowledged it and which action helped. For a repeated slow-acknowledgement condition, update the existing investigation instead of opening another identical one.
Alertmanager supplies grouping, inhibition and silences; its documentation describes their different roles. Grouping batches related notifications. Inhibition suppresses a notification while a related higher-priority alert is active. A silence is an explicit, time-bounded suppression. None fixes an incorrect SLI or a forgotten incident after its page clears. Prometheus documentation
Example#
This small executable check isolates the denominator error:
from fractions import Fraction
attempts = [100] * 11 + [1]
bad = [0] * 11 + [1]
by_request = Fraction(sum(bad), sum(attempts))
by_minute = sum(Fraction(b, n) for b, n in zip(bad, attempts)) / 12
print(f"request-weighted: {float(by_request) * 100:.6f}%")
print(f"minute-weighted: {float(by_minute) * 100:.6f}%")
request-weighted: 0.090827%
minute-weighted: 8.333333%
The full reference script checks both incidents, exact threshold boundaries, a complete outage below the volume floor and a window with no observations. Run it with python3 scripts/notes/check-slo-renewal.py --check-notes. It uses Python’s standard library and checks the values stated in both languages.
In Prometheus, a ratio-of-sums query for the recent window could be:
sum(increase(answer_save_bad_total[3m]))
/
sum(increase(answer_save_attempts_total[3m]))
The fictional counters must count the same eligible attempts, and the bad counter must include late acknowledgements as well as failures. Emit the bad series even when it is zero. In a real multi-service deployment, select or group matching service labels rather than summing unrelated traffic. Apply increase before aggregation so each counter’s reset can be handled; it extrapolates between scrape samples, so its result need not be an integer. Prometheus query functions
This query illustrates instrumentation, not an executed Prometheus rule package. The Python check uses complete buckets and does not model scrapes, resets, missing time series or notification delivery. Before deploying equivalent rules, test those cases with promtool test rules and realistic sample intervals; an alert expression without for activates on its first matching evaluation. Prometheus alerting rules
Limitations#
- Acknowledgement is not proof that the stored answer is correct or survives every future failure. Audit data integrity separately.
- A volume floor can hide a complete low-traffic outage. The script demonstrates this with one failing request per minute; use a separate reachability/durability probe and an appropriate low-volume policy.
- No data is not success. Missing telemetry needs its own check.
- The fixture is deterministic and contains only three inserted disturbances. It establishes its arithmetic, not real-world precision, recall or a universal choice of windows.
- Independence, constant traffic and complete observations are assumptions to check individually. The request-weighted calculation does not require constant traffic; the shortcut does.
Next#
The detector identifies failed or delayed saves. Resilience and capacity examines timeouts, retries, circuit breakers and load shedding: the mechanisms that determine how many such failures a dependency can cause.
References#
- B. Beyer, C. Jones, J. Petoff, N. R. Murphy (eds.). Site Reliability Engineering, 2016, ch. 4: Service Level Objectives. Conceptual reference for indicators, objectives and reliability decisions.
- S. Thurgood, with J. Frame, A. Lenton, C. Quinito, A. Tolchanov and N. Trdin. Alerting on SLOs, The Site Reliability Workbook, 2018. Conceptual reference for error-budget burn and confirmation over more than one window; the service policy, counts, experiment and detector parameters here are newly specified.
- Prometheus. Query functions, alerting rules, rule testing, and Alertmanager. Checked 13 November 2026 for counter reset/extrapolation, evaluation and notification semantics.
The fictional observations, reference program and counting figure were authored for this note by Fedor Pakhurov with AI assistance. They do not use an external incident dataset or an upstream notebook’s results.