Everyone thinks SLO tracking is a ratio and a gauge. “Count the good requests, count the total, divide, show a number, email someone when it drops below 99.9%.” Then the interviewer piles on the constraints that turn it into a real system: it is not one service, it is hundreds of SLOs across dozens of teams, each defined over a rolling 28-day window; the budget for a 99.9% target over a month is tiny (about 43 minutes of downtime), so you have to notice it draining fast - a sudden burst that will exhaust the whole month in two hours must page in minutes, not after the fact; the same request event can arrive twice (retries, at-least-once delivery from the event bus), and if you double-count it your error rate is a lie; and an alert that fires late, fires twice, or silently never fires at all is the difference between catching an incident and explaining in the postmortem why nobody was paged.
An SLO platform is deceptive because the naive “sum two counters and divide” demo works perfectly for one service on a dashboard and then dies against the real shape of the workload: a high-volume stream of request outcome events that must be folded into sliding-window good and total counts per SLO at sub-minute granularity, a deduplication requirement so every event counts exactly once no matter how many times it is delivered, a rolling 28-day budget whose rate of consumption (the burn rate) is what actually matters, and a multi-window multi-burn-rate alerting scheme that has to fire exactly once and never miss a silent exhaustion. The whole design comes down to four decisions: how you ingest and deduplicate a firehose of outcome events deterministically, how you maintain sliding-window counts per SLO cheaply without rescanning history, how you compute burn rate over multiple time windows continuously, and how you fire multi-window alerts exactly once with no gaps. All of it while ingestion never blocks, the budget number is trustworthy, and the pager fires before the month’s budget is gone, not after.
Let me do it properly.
Functional Requirements (FR)
In scope:
- Define SLOs. A user defines an SLO as
(SLI, target, window)- for example “99.9% of checkout requests return non-5xx within 300ms, measured over a rolling 28 days.” The SLI (service level indicator) is a ratio: good events / valid events. Support both request-based SLIs (fraction of good requests) and time-based / windowed SLIs (fraction of good 1-minute windows), and support latency, availability, and correctness indicators. - Ingest outcome events. Accept a stream of events, each being
(slo_id, event_id, timestamp, outcome)where outcome classifies the event as good, bad, or excluded (not counted against the budget). This is the write firehose - derived from request logs, metrics, or application emission. - Maintain good/total counts in sliding windows. For each SLO keep running counts of good and total (valid) events over the rolling window and over short sub-windows (1m, 5m, 1h, 6h) at sub-minute granularity, so current compliance and burn rate are always fresh.
- Deterministic deduplication. The same
event_iddelivered more than once (retries, at-least-once bus semantics) must be counted exactly once. The SLI must not be distorted by duplicates. - Compute error budget and burn rate. Error budget =
(1 - target) * total_valid_events(or total window time). Track budget consumed, budget remaining, and the burn rate = how fast the budget is being spent relative to the rate that would exhaust it exactly at the window’s end. - Multi-window burn-rate alerting. Fire alerts when the budget is burning too fast, using the Google SRE multi-window multi-burn-rate scheme (fast burn over a short window for pages, slow burn over a long window for tickets), with a short and long window AND condition to suppress false positives. Each alert fires exactly once per episode; no budget exhaustion is silently missed.
- Dashboards and reporting. Show per-SLO remaining budget, burn-rate trend, compliance over the window, and a history of alert episodes.
Explicitly out of scope (say it so you own the scope):
- The metrics / logging pipeline itself. How request outcomes are measured and emitted (the instrumentation, the metrics TSDB, log parsing) is upstream. We design from “outcome events arriving” onward. This platform consumes an observability pipeline; it is not one. [If the interviewer wants the TSDB too, that is a separate, larger design.]
- Incident management and on-call. Escalation policies, schedules, and incident tracking (the PagerDuty layer) consume our alerts. We decide when to alert and hand off the notification.
- General-purpose alerting on arbitrary metrics. This is specifically error-budget alerting - burn rate against a defined SLO - not “CPU > 80%”. Threshold alerting on raw metrics is the monitoring system’s job.
- Capacity planning / forecasting. Predicting when the budget will run out via ML is a layer on top; we compute the deterministic burn rate and the simple linear projection, and note where a forecaster would attach.
- Deployment gating / release automation. Using remaining budget to block deploys (freeze when budget is low) is a downstream consumer of our budget API; we expose the number and the policy engine lives elsewhere.
The one decision that drives everything: error budget tracking is a deduplicated streaming-aggregation problem where the master variable is the rate of budget consumption over sliding windows, so it must fold a firehose of outcome events into exactly-once sliding-window counts at sub-minute granularity and evaluate multi-window burn-rate conditions continuously so alerts fire exactly once before the budget is gone. So the design is dominated by a stream processor that deduplicates and maintains windowed good/total counts per SLO, a time-bucketed count store that makes any window queryable without rescanning raw events, and a multi-window alert evaluator with per-episode exactly-once firing.
Non-Functional Requirements (NFR)
- Scale: on the order of hundreds of SLOs (say up to 10,000 across a large org), each backed by an underlying request stream. High-traffic SLOs see 100K+ requests/sec; aggregate outcome-event ingest across all SLOs on the order of 1-2M events/sec at peak. The number of SLOs is modest; the event volume feeding them is the firehose.
- Latency: ingest is fire-and-forget, accept an event in a few milliseconds. End-to-end freshness - an outcome event to it being reflected in the burn-rate number - target under ~30 seconds (sub-minute granularity is the whole point). Burn-rate alert decision latency on the order of seconds to a minute after a window’s condition is met, because a fast burn can eat the month in a couple of hours.
- Availability: the ingest path and the alert-evaluation path are critical and target 99.9%+. The dashboard/query path can degrade to slightly stale. Crucially, the alerting path must be more available than the services it watches - if it is down during an incident, you burn the budget unseen.
- Consistency: the budget number must be correct, not approximate, because it is used to make go/no-go decisions (freeze releases, page humans) and reported to stakeholders. This is a sharp contrast with a raw metrics system that tolerates dropped samples. We require exactly-once counting (via deduplication + idempotent aggregation), eventual convergence within the freshness window, and deterministic recomputation (reprocessing the same events yields the same budget).
- Durability: counts and alert-episode state must survive node failure - a lost count means a wrong budget, and a lost alert-episode record means a double-page or a missed page. Raw events need enough retention to reprocess (replay) a window if an SLO definition changes or a bug is fixed - say 35+ days to cover a 28-day window plus slack.
- Determinism and auditability are first-class. Because budget drives decisions, the platform must be able to explain why the budget is what it is: which events, counted once, over which window. Non-determinism (double counts, dropped events, clock-driven window ambiguity) is a correctness bug, not a tolerable approximation. This is the opposite stance from a best-effort metrics pipeline and most candidates miss it.
Back-of-the-Envelope Estimation (BoE)
Let me ground the design in numbers.
Traffic:
SLOs tracked: ~10,000
Avg events/sec per SLO: ~150 (wide spread: many tiny, few huge)
Hot SLOs: 100K+ events/sec each
Aggregate outcome events/sec = ~1,500,000/sec sustained (~1.5M/sec)
Incident / retry spike (~2x) ≈ ~3,000,000/sec (size for this)
Like all monitoring load, event volume is anti-correlated with health: during an incident the error rate spikes, retries multiply (which both increase volume and produce duplicate deliveries), and more engineers open dashboards. So the dedup path and the aggregation path get their worst load exactly when correctness matters most. We size ingest for ~3M events/sec.
Read vs write:
Writes (outcome events): ~1.5M/sec sustained, ~3M/sec peak. The firehose.
Reads:
- Alert evaluation: 10,000 SLOs, each evaluated every ~15s, and each SLO
checks MULTIPLE burn-rate windows (1h, 6h, 1d, 3d).
= 10,000 / 15s ≈ 667 SLO-evaluations/sec, each reading a handful of
pre-aggregated window counts (cheap, O(1) per window, not a scan).
- Dashboards: thousands of panels polling every 15-30s. Low thousands/sec,
each reading pre-aggregated counts. Cheap because counts are materialized.
The asymmetry is the key insight: writes are a firehose but reads are O(1) lookups of pre-aggregated counts, provided we materialize the windowed counts at write time instead of scanning raw events at read time. If a read had to sum 28 days of raw events per SLO, alert evaluation would be hopeless. The entire design hinges on moving the aggregation to the write path.
Storage:
Pre-aggregated counts (the hot, queried data):
Granularity: 1-minute buckets. Per SLO per minute store (good, total) = 2 counters.
Minutes in 28-day window: 28 * 1440 = 40,320 buckets/SLO.
Per bucket: slo_id(8) + ts(8) + good(8) + total(8) ≈ 32 bytes.
Per SLO window: 40,320 * 32 ≈ ~1.3 MB.
10,000 SLOs: ~13 GB of count buckets. Small. Fits in a cache tier easily.
Dedup state (the expensive part):
Must remember which event_ids were seen, within a dedup window (say ~10 min
of possible duplicate delay). At 1.5M events/sec * 600s = 900M event_ids in
flight. Even at 16 bytes/id that is ~14 GB of dedup keys at any moment -
and this is the structure under the most pressure.
Raw event log (for replay / recompute):
1.5M/sec * 86,400 ≈ 130B events/day. At ~40 bytes compressed ≈ ~5 TB/day.
Retain ~35 days for reprocessing: ~180 TB. Cold, sequential, in object storage.
Three things fall out. First, the queried data is tiny - 13 GB of count buckets for the whole org - because we pre-aggregate; this is what makes O(1) reads possible. Second, dedup state is the pressure point, not the counts: ~900M event_ids in flight is the structure that decides whether counting is exactly-once, and it must be fast and bounded. Third, raw events are large but cold - kept only for replay, stored sequentially and cheaply, never on the hot read path. The design optimizes the small hot path and tolerates the large cold path.
Burn rate math (why the budget drains fast):
Target 99.9% over 28 days. Error budget = 0.1% of events (or of time).
If the window is "time-based": 0.1% of 28 days = 40.32 minutes of allowed badness.
Burn rate = (observed error rate) / (budget error rate).
Burn rate 1x -> budget lasts exactly 28 days (consumed evenly).
Burn rate 14.4x -> budget gone in 28d / 14.4 ≈ ~2 days.
Burn rate 1000x (total outage) -> 40 min of budget gone in ~2.4 minutes.
A 1-hour fast burn at 14.4x consumes 14.4 * (1h/28d) = 2.14% of the MONTH's
budget in that single hour. Two such hours and you have spent a month's slack
before lunch. THIS is why short-window fast-burn alerting must page in minutes.
The arithmetic is the reason the whole system exists: a 99.9% target gives you ~40 minutes of budget for a month, and a bad enough burst spends it in minutes. Alerting on “budget already exhausted” is too late; you alert on burn rate - the derivative - so you catch a fast burn while there is still budget to protect.
Bandwidth:
Ingest: ~1.5M events/sec * ~30 bytes on the wire (batched, compressed)
≈ 45 MB/sec ≈ 360 Mbps inbound, spread across an ingest fleet.
Query: dashboard + alert reads are pre-aggregated counts, KBs each,
low thousands/sec -> a few MB/sec. A non-issue.
Ingest bandwidth is modest when producers batch and compress. The scarce resources are sustained dedup throughput, RAM for in-flight dedup keys and in-memory window counts, and the correctness of the aggregation. Size for those.
High-Level Design (HLD)
The system is a streaming pipeline: outcome events land on a partitioned log, a stateful stream processor deduplicates them and folds them into per-SLO per-minute count buckets, a count store materializes those buckets plus pre-rolled multi-window sums, a budget/burn-rate service reads the materialized counts, and an alert evaluator runs the multi-window burn-rate scheme with exactly-once per-episode firing. An SLO config service holds definitions.
WRITE PATH (outcome events, ~1.5-3M/sec, fire-and-forget)
┌──────────────────────────────────────────────────────────────────────────────┐
│ Producers (log pipeline / metrics / app SDK) --push--> Ingest Gateway (LB) │
└───────────────────────────────────────┬────────────────────────────────────────┘
│ batched, compressed events
┌─────────▼──────────┐
│ Ingest Service │ (stateless, fleet)
│ - validate / map │
│ event -> slo_id │
│ - classify outcome│ (good|bad|excluded)
│ - assign partition│ by slo_id (key)
└─────────┬──────────┘
│ append, key = slo_id
┌──────────────▼───────────────┐
│ KAFKA (durable event log) │ absorbs spikes,
│ partitioned by slo_id │ enables replay,
│ ~35 day retention │ decouples stages
└───┬───────────────────────┬────┘
┌───────────▼──────────┐ ┌─────────▼────────────┐
│ Stream Processor │ │ Stream Processor │ ...N
│ (one per partition) │ │ (owns a set of SLOs) │
│ - DEDUP (event_id) │ └─────────┬────────────┘
│ - fold into 1-min │ │
│ (good,total) bucket│ per-SLO per-minute (good,total)
│ - local state store │ │ upserts (idempotent)
└───────────┬──────────┘ │
┌───────────▼──────────────────────────▼──────────────┐
│ COUNT STORE (per-SLO per-minute buckets) │
│ + pre-rolled window sums (1h,6h,1d,3d,28d) │
│ hot buckets in memory/cache, buckets persisted │
└───────────┬──────────────────────────┬──────────────┘
┌───────────▼──────────┐ ┌───────────▼─────────────┐
│ Budget / BurnRate Svc │ │ Alert Evaluator │
│ - remaining budget │ │ - multi-window, │
│ - burn rate per win │ │ multi-burn-rate │
│ - compliance % │ │ - short AND long gate │
└───────────┬──────────┘ │ - per-EPISODE dedup │
│ └───────────┬─────────────┘
┌─────────────▼──────┐ │ fire once
│ Dashboard API │ ┌─────▼──────┐
│ (panels, cache) │ │ Notifiers │ page/Slack/ticket
└─────────┬──────────┘ └────────────┘
┌─────────▼────┐ ┌──────────────────────────┐
│ UI │ │ SLO Config Service (SQL)│ definitions,
└──────────────┘ │ targets, windows, rules │ versioned
└──────────────────────────┘
RAW EVENT LOG (Kafka 35d + archived to object store) ----> REPLAY path
used to recompute counts on SLO-definition change or bug fix.
Request flow - an outcome event being written (the write hot path):
- A producer (the log/metrics pipeline, or an application SDK) emits an outcome event and pushes a batch to the ingest gateway. Each event carries a stable
event_id(ideally derived from the request id, so retries of the same request produce the same id - this is what makes dedup deterministic) and a timestamp. - The stateless Ingest Service validates the event, maps it to the owning
slo_id(an event may feed more than one SLO; it is fanned out), classifies the outcome (good / bad / excluded) per the SLO’s SLI definition, and appends it to the durable event log (Kafka) partitioned byslo_idso all events for one SLO land on one partition in order and are processed by one stream-processor instance. The gateway acks after the durable append - fire-and-forget. - The Stream Processor that owns the partition consumes events in order. For each event it runs deduplication: if this
event_idhas been seen within the dedup window, drop it; otherwise record it and proceed. It then folds the event into the current 1-minute bucket for that SLO:total += 1, andgood += 1if the outcome is good (excluded events increment neither). The bucket and the dedup state live in the processor’s local, replicated state store (a changelog-backed RocksDB, the Kafka Streams / Flink pattern). - Completed 1-minute buckets are upserted into the Count Store idempotently (keyed by
(slo_id, minute), so a reprocessed bucket overwrites rather than adds). The count store also maintains pre-rolled window sums - running sums over 1h, 6h, 1d, 3d, and the full 28d - updated incrementally as buckets roll in and age out, so a burn-rate read is O(1).
Request flow - the read / alert paths:
- Budget / burn-rate read: the Budget Service, given an SLO, reads its pre-rolled window sums from the count store. Error budget =
(1 - target) * total_28d; consumed =bad_28d; remaining = budget - consumed. Burn rate for a window =(bad_window / total_window) / (1 - target). All O(1) lookups - no raw scan. - Alert evaluation: the Alert Evaluator runs each SLO’s multi-window multi-burn-rate rules on a loop (every ~15-30s). It reads the pre-rolled burn rates for the configured window pairs (e.g. 1h and 5m for the fast page; 6h and 30m for the slow page) and fires only when both the long and short window exceed the threshold. On a state transition into firing, it writes a per-episode record keyed by
(slo_id, alert_tier, episode)- so the notification is emitted exactly once per episode even though the condition stays true across many evaluation ticks and even if the evaluator is replicated.
The key architectural insight: the budget is a deduplicated streaming aggregation, so you count each event exactly once at the write path and materialize every window you will ever query, turning every read - burn rate, compliance, alerting - into an O(1) lookup instead of a scan over history. Dedup makes the count correct; pre-rolled windows make it cheap; per-episode records make alerts fire exactly once; and the raw event log makes the whole thing replayable and auditable. The stream processor is the heart - it is where correctness (dedup + idempotent fold) is enforced before any number is ever read.
Component Deep Dive
Four hard parts: (1) deterministic deduplication of the event firehose, (2) maintaining sliding-window counts cheaply at sub-minute granularity, (3) computing burn rate and firing multi-window alerts, and (4) making alerts fire exactly once with no silent misses. I will walk each from naive to scalable.
1. Deterministic Deduplication: Counting Each Event Exactly Once
The event bus is at-least-once; retries during incidents multiply duplicates. If we count a duplicate, the error rate (and the budget) is wrong. This must be deterministic - reprocessing the same stream must yield the same counts.
Approach A: Just count every event as it arrives (the naive instinct)
Increment total (and good) for every event the processor sees. No dedup.
Where it breaks: at-least-once delivery means the same request outcome is delivered multiple times - a Kafka consumer rebalance replays uncommitted offsets, a producer retries a timed-out send, an upstream retries the request itself. During an incident, retry storms can inflate counts 2-5x, and they inflate unevenly (bad events retry more than good ones because failing requests get retried). So your error rate is not just noisy, it is biased toward looking worse than reality exactly when you most need the number to be true. The budget becomes fiction and you cannot defend it in a release-gate meeting. “Approximately counted” is not acceptable when the number drives decisions.
Approach B: Dedup by event_id within a bounded window, in processor-local state
Give every event a stable event_id and remember which ids were counted, so a re-delivery is dropped:
- Stable id at the source. The
event_idmust be derived from the request identity (e.g. a hash of the trace id / request id), not generated fresh on each delivery - otherwise a retry looks like a new event and dedup is impossible. This is the single most important upstream contract. If the source cannot provide a stable id, dedup degrades to best-effort and you say so. - Keyed, partitioned dedup state. Because the event log is partitioned by
slo_id, all deliveries of one event for one SLO go to the same processor instance, so dedup is a local lookup - no distributed coordination needed. The processor keeps a set of seenevent_ids in its local state store (RocksDB, replicated via a Kafka changelog topic so it survives restart). - Bounded dedup window. You cannot remember every id forever (900M ids in flight already). Keep ids for a dedup window sized to the maximum plausible duplicate delay (say 10-15 minutes - longer than any retry/rebalance lag). Ids older than the window are evicted. A duplicate delayed beyond the window is a rare miss and is bounded.
- Probabilistic pre-filter to save memory. Front the exact set with a per-minute Bloom filter / rotating cuckoo filter: a definite-miss skips the exact lookup entirely; a maybe-hit falls through to the exact RocksDB check. This keeps the hot path mostly in a compact in-memory filter and the exact state on disk, bounding RAM for the ~900M in-flight ids.
- Idempotent fold makes replay safe. Dedup handles live duplicates; for reprocessing (replaying a window after a bug fix), the fold into buckets is idempotent by construction - a bucket is computed as
count of distinct event_ids in that minute, upserted (overwrite), not incremented. So replaying the same events recomputes the identical bucket. Determinism end to end: same events in, same budget out.
on event e (slo_id, event_id, ts, outcome):
if filter[minute(ts)].maybe_contains(event_id):
if state.contains(event_id): # exact check
dup_dropped++; return # already counted
filter[minute(ts)].add(event_id)
state.put(event_id, ts) # TTL = dedup window
b = bucket(slo_id, minute(ts))
b.total += 1
if outcome == good: b.good += 1 # excluded -> neither
The mindset: deduplication is a correctness requirement, not an optimization. A stable source id plus partition-local exact dedup (fronted by a probabilistic filter and bounded by a window) plus an idempotent upsert fold gives exactly-once effect without distributed transactions - the number is true, and reprocessing is deterministic.
2. Sliding-Window Counts: Sub-Minute Freshness Without Rescanning History
We need good/total over a rolling 28-day window and over short windows (1m/5m/1h/6h) that update every few seconds. Scanning raw events per read is impossible at this volume.
Approach A: Compute the window on read by scanning raw events (naive)
On each burn-rate read, scan the raw event log for the SLO over the requested window and count.
Where it breaks: a 28-day window for a hot SLO is billions of raw events; even a 1-hour window is hundreds of millions for a 100K/sec SLO. Alert evaluation runs this ~667 times a second across all SLOs and windows. Scanning raw events per read is many orders of magnitude too expensive - evaluation would fall behind real time, which is the one thing it must never do during a fast burn. Read-time aggregation over raw events does not scale past a toy.
Approach B: Materialize fixed 1-minute buckets, then maintain rolling window sums incrementally
Move all aggregation to the write path and keep the windows as incrementally-maintained running sums:
- Fixed-size 1-minute buckets are the quantum. The processor folds events into immutable, closed 1-minute
(good, total)buckets keyed by(slo_id, minute). One minute is the granularity knob - small enough for sub-minute-ish freshness, large enough that 28 days is only 40,320 buckets per SLO (~1.3 MB). Within the current minute, a partial in-memory bucket gives live freshness; it is finalized when the minute closes. - Rolling window sums via add-new / subtract-old. A sliding 1-hour sum is maintained as a running total: when a new minute bucket closes, add it; when a bucket ages past the window edge, subtract it. This is the classic sliding-window-sum over fixed buckets - O(1) update per minute per window, no rescan. We keep running sums for every window the system queries: 5m, 1h, 6h, 1d, 3d, 28d.
Buckets (immutable, 1-min): [10:00]=(g,t) [10:01]=(g,t) ... [10:59]=(g,t)
Rolling 1h sum at 11:00 = sum of buckets (10:00 .. 10:59)
At 11:01: sum += bucket[11:00]; sum -= bucket[10:00] # O(1), no scan
Each window (5m,1h,6h,1d,3d,28d) keeps its own running (good,total) sum.
- Why not just one big 28-day sum? Because burn-rate alerting needs multiple window lengths simultaneously (a 1h fast-burn window and a 6h slow-burn window are different numbers), and because the budget is a 28-day ratio while the alert is a short-window ratio. We maintain all of them off the same immutable bucket series, so they are always mutually consistent (all derived from the same buckets) and each is O(1).
- Granularity vs cost trade. Finer buckets (10s) give fresher numbers but 6x more buckets and state; coarser (5m) are cheaper but a fast burn is detected up to a bucket-width late. One minute is the standard compromise: a total-outage burn (1000x) still consumes only ~2.4 min of budget before the first closed bucket reflects it, and the live partial bucket narrows even that.
- Late and out-of-order events. An event timestamped 10:59 arriving at 11:02 must land in the 10:59 bucket, not the current one (correctness: the budget is by event time, not arrival time). Buckets stay mutable for a short grace period (a few minutes) before being sealed; a genuinely late event past the grace window updates the sealed bucket and triggers a recompute of the affected rolling sums (cheap, bounded) - the determinism requirement means we fix the number rather than drop the event.
The trade is explicit: we pay a fixed per-minute aggregation cost on the write path and a small amount of state (13 GB for the org) to turn every windowed read into an O(1) running-sum lookup. Read-time scans are impossible at this scale; write-time materialization of every queried window is the only shape that gives sub-minute freshness and cheap reads.
3. Burn Rate and Multi-Window Alerting: Catching a Fast Burn Before the Budget Is Gone
The budget being empty is the failure; the point is to alert on the rate while budget remains. A single threshold is either too slow or too noisy.
Approach A: Alert when remaining budget drops below a threshold (naive)
Page when remaining budget < 10% (or when the 28-day error rate exceeds the target).
Where it breaks: two opposite failures. First, too late for fast burns: a total outage spends 40 minutes of a month’s budget in minutes; by the time the 28-day number crosses the target you have already blown the whole month and the incident is long underway. The 28-day ratio is a lagging indicator - it barely moves during a short severe burst because the burst is tiny relative to a month of traffic. Second, too noisy for slow burns if you shorten the window: alert on the 5-minute error rate and every transient blip pages, so on-call ignores the pager. A single window cannot be both fast enough for severe burns and quiet enough to be trustworthy. You need to react to rate, over multiple timescales.
Approach B: Multi-window, multi-burn-rate alerts with a short-window confirmation gate
Adopt the Google SRE multi-window multi-burn-rate scheme: define several alert tiers, each a pair of windows and a burn-rate threshold, firing only when both windows agree:
- Burn rate is the normalized consumption rate.
burn_rate = (errors_in_window / valid_in_window) / (1 - target). A burn rate of 1 consumes the budget exactly over the full SLO window; 14.4 consumes it in ~2 days; higher is faster. Alerting on burn rate (a short-window number) catches severe bursts immediately because the short-window error rate spikes even though the 28-day ratio barely twitches. - A tier per severity, with budget-consumed thresholds. The canonical tiers for a 28-day window:
| Tier | Long window | Short window | Burn rate | Budget consumed if sustained | Action |
|---|---|---|---|---|---|
| Fast / critical | 1 hour | 5 min | 14.4x | ~2% of month in 1h | Page now |
| Medium | 6 hours | 30 min | 6x | ~5% of month in 6h | Page |
| Slow | 1 day | 2 hours | 3x | ~10% of month in 1d | Ticket |
| Very slow | 3 days | 6 hours | 1x | ~10% of month in 3d | Ticket |
- The short-window AND gate is what kills false positives and auto-resolves. Each tier fires only when both the long window and a short window (typically 1/12th the long) exceed the threshold. The long window gives significance (a sustained problem, not a 30-second blip); the short window confirms the problem is still happening right now. Crucially, the short window also makes the alert auto-resolve fast: once the burst stops, the short window drops below threshold within minutes and the alert clears, instead of staying lit for the whole long window. Long-window-only alerts fire late and resolve far too late; the short-window gate fixes both.
fire tier T for SLO s iff:
burn_rate(s, T.long_window) >= T.threshold
AND burn_rate(s, T.short_window) >= T.threshold
# both numbers come from O(1) pre-rolled window sums (section 2)
- Why multiple tiers. A severe fast burn trips the 1h/5m tier in minutes and pages. A slow steady erosion never trips the fast tier (the 1h rate is modest) but does trip the 1-day/3-day tiers and files a ticket. Together the tiers cover the whole spectrum from “outage now” to “slowly bleeding the budget,” each with an action proportional to severity. No single window does this.
- Evaluation is cheap and sharded. Each SLO’s tiers read only pre-rolled window sums (O(1)), so the evaluator is bounded by
SLOs * tiers, not by event volume or retention. The evaluator fleet is sharded byslo_idso it scales horizontally and is isolated from the dashboard read path - a heavy dashboard never starves alert evaluation.
The point: burn rate turns the lagging 28-day budget into a leading indicator, and the multi-window AND gate makes that indicator both fast (short window) and trustworthy (long window), with a tier and an action for every severity. You alert on the derivative, confirmed over two timescales, so you page in minutes for an outage and file a ticket for a slow bleed - and never on a blip.
4. Exactly-Once Firing and No Silent Misses
An alert condition stays true across many evaluation ticks; the evaluator is replicated for availability. We must fire once per episode, never twice, and never silently skip a real exhaustion.
Approach A: Fire whenever the condition is true (naive)
Each evaluation tick that sees the condition true sends a notification.
Where it breaks: the condition is true for the duration of the incident - minutes to hours - and the evaluator ticks every 15s, so a single episode pages dozens of times. Worse, you run the evaluator replicated (it must be highly available), so two replicas both see the condition true and both page - duplicate pages per tick. On-call drowns in repeats for one incident and learns to mute the pager, which means the next real page is missed. Stateless “fire if true” is a page storm.
Approach B: Per-episode state machine with an idempotent firing record
Model each SLO-tier as a state machine and make the firing action idempotent on a durable per-episode key:
- Episode state machine. Per
(slo_id, tier)keep stateinactive -> firing -> resolved. On the first tick where the AND condition becomes true, transition to firing and emit the notification. While it stays true, stay in firing and emit nothing. When both windows drop below threshold, transition to resolved and emit a single resolve notification. One episode = one page + one resolve. - Durable episode record for exactly-once across replicas. The transition-to-firing writes a record keyed by
(slo_id, tier, episode_id)to a strongly-consistent store with a conditional insert (insert-if-not-exists / compare-and-set). Whichever replica wins the CAS sends the page; the loser sees the record already exists and does nothing. This makes firing exactly once even with a replicated evaluator - the durable record, not the evaluator’s memory, is the source of truth.episode_idis derived deterministically (e.g.slo_id|tier|first_true_minute) so both replicas compute the same key.
tick for (slo_id, tier):
cond = long_ok AND short_ok
st = episode_store.get(slo_id, tier)
if cond and st.state != firing:
ep = episode_id(slo_id, tier, now)
if episode_store.cas_insert(slo_id, tier, ep, FIRING): # atomic, once
notify(PAGE, slo_id, tier, ep) # only the winner
# loser: record exists -> no-op
if not cond and st.state == firing:
episode_store.cas_update(st, RESOLVED)
notify(RESOLVE, slo_id, tier, ep)
- No silent misses: the evaluator must be live and is itself monitored. Exactly-once is only half the guarantee; the other half is that the evaluator never silently stops evaluating an SLO. Defenses: (a) the evaluator writes a heartbeat / last-evaluated timestamp per SLO, and a meta-monitor pages if any SLO has not been evaluated within N intervals (a dead-man’s switch - “the thing that watches the budget must be watched”); (b) evaluation is driven off the same durable count store, so a restarted evaluator resumes from current state and re-derives episode state from the durable record, never missing a transition; (c) the
episode_storerecord lets a restarted or failed-over replica know an episode is already firing and not re-page, and also know an in-progress episode needs a resolve. - Notification delivery is retried and idempotent. Sending the page is a durable, retried action keyed by
episode_id, so a delivery retry does not double-page and a crashed notifier resumes. A dropped page during an incident is the worst failure, so delivery is at-least-once with episode-id idempotency at the notifier. - Flap damping without hiding real burns. The short-window gate already auto-resolves fast; to avoid rapid re-fire on a bursty-but-ongoing incident, require the condition to be false for a short hysteresis period before resolving, so a burst that dips for one tick does not resolve-and-re-page. This is tuned small (a minute or two) so it never hides a genuinely new episode.
Put together: a per-episode state machine plus a durable compare-and-set firing record gives exactly-once pages even with a replicated evaluator, while per-SLO heartbeats and a dead-man’s-switch meta-monitor guarantee no budget exhaustion is ever silently missed. The durable record - not any process’s memory - is the authority on whether an episode has fired, which is what makes “exactly once” hold across restarts, failovers, and replicas.
API Design & Data Schema
Ingest API (the write plane)
POST /v1/events
Content-Type: application/x-protobuf (batched, snappy-compressed)
body: [
{ event_id:"req_7f3a9c", # STABLE id derived from request/trace id
slo_ids:["slo_checkout_avail"], # one event may feed several SLOs
ts: 1764633600000,
outcome:"good" }, # good | bad | excluded
...
]
204 No Content -> accepted & durably logged. Async aggregation.
429 Too Many Requests -> producer over rate limit (with Retry-After)
Notes:
- Fire-and-forget: 204 after the durable Kafka append, not after aggregation.
- event_id MUST be stable across retries or dedup degrades to best-effort.
- excluded outcomes count toward neither good nor total (e.g. requests from
load tests, or 4xx client errors you choose not to count against the SLO).
Query API (the read plane)
# Current budget + burn rate for an SLO (O(1), from pre-rolled sums)
GET /v1/slos/{slo_id}/budget
200 OK
{
"slo_id":"slo_checkout_avail",
"target":0.999, "window":"28d",
"valid_28d": 5_184_000_000,
"bad_28d": 2_100_000,
"budget_total": 5_184_000, # (1-target)*valid
"budget_consumed": 2_100_000,
"budget_remaining_pct": 59.5,
"burn_rate": { "5m":0.4, "1h":0.6, "6h":1.1, "1d":0.9, "3d":0.8 },
"compliance_28d": 0.99959
}
# Historical burn-rate / compliance series for a dashboard panel
GET /v1/slos/{slo_id}/series?metric=burn_rate&window=1h&from=..&to=..&step=5m
200 OK { "points":[ {"ts":..,"value":0.6}, ... ] }
# Alert episode history (auditability)
GET /v1/slos/{slo_id}/episodes?from=..&to=..
200 OK { "episodes":[ {"tier":"fast","episode_id":"..","fired_at":..,"resolved_at":..} ] }
Config / control plane (SLO definitions)
POST /v1/slos
{ "slo_id":"slo_checkout_avail",
"sli": { "type":"request", # request | windowed
"good":"status < 500 AND latency_ms < 300",
"valid":"status NOT IN (401,403)" }, # exclusion rule
"target":0.999,
"window":"28d",
"alert_tiers":[
{"tier":"fast","long":"1h","short":"5m","burn_rate":14.4,"severity":"page"},
{"tier":"slow","long":"1d","short":"2h","burn_rate":3,"severity":"ticket"}
] }
-> versioned; changing sli/target triggers an optional REPLAY to recompute.
GET /v1/slos/{slo_id} # definition + version
POST /v1/slos/{slo_id}/replay # recompute counts from raw log (new definition / bug fix)
Data model: SQL for config/episodes, a bucket store for counts, Kafka for raw
SLO config + alert episodes (SQL - small, relational, needs transactions/consistency):
slos(slo_id PK, tenant, sli_json, target, window, version, created_at)
alert_tiers(tier_id PK, slo_id FK, long_window, short_window, burn_rate, severity)
alert_episodes(slo_id, tier, episode_id, state[firing|resolved],
fired_at, resolved_at,
PRIMARY KEY (slo_id, tier, episode_id)) # CAS insert = exactly-once
index on (slo_id, state) # find active episodes fast
slo_eval_heartbeat(slo_id PK, last_evaluated_at) # dead-man's-switch source
Why SQL here: episode exactly-once relies on a conditional insert (CAS) and the config needs transactional, versioned, strongly-consistent reads. This is low-volume control-plane data - a relational store is the right tool.
Count store (per-SLO per-minute buckets + rolling window sums - purpose-built, not SQL):
# Immutable 1-minute buckets, keyed and range-scannable by (slo_id, minute)
bucket: key = (slo_id, minute_ts) -> { good:int64, total:int64, sealed:bool }
partitioned/sharded by slo_id; hot recent buckets in memory/cache,
older buckets persisted (LSM/KV). 40,320 buckets/SLO for 28d (~1.3 MB).
# Pre-rolled rolling sums, O(1) read, maintained add-new/subtract-old
window_sum: key = (slo_id, window) -> { good:int64, valid:int64, updated_minute }
windows = {5m,1h,6h,1d,3d,28d}. This is what budget/alert reads hit.
Why a bucket KV store, not SQL: the access pattern is keyed upserts and small range scans over (slo_id, minute) plus O(1) rolling-sum reads, at high write volume. A row-per-event relational table would be the Approach-A disaster from section 2. The buckets are an append-mostly, idempotent-upsert, range-scan workload - a KV / LSM store, not OLTP.
Raw event log (Kafka + object-store archive - for replay/audit):
topic: outcome-events, partitioned by slo_id, retention 35d (then archived cold).
record: (event_id, slo_id, ts, outcome, source_meta)
Replay: re-run the stream processor from an offset to recompute buckets
deterministically when an SLO definition changes or a dedup/classify bug is fixed.
Dedup state (processor-local, changelog-backed - for exactly-once counting):
seen_ids: key = event_id -> first_seen_ts, TTL = dedup window (~10-15 min)
RocksDB local state, replicated via a Kafka changelog topic for recovery,
fronted by rotating per-minute Bloom/cuckoo filters in RAM.
Why this split - SQL for config/episodes, a bucket KV store for counts, Kafka for raw replay, and processor-local RocksDB for dedup: each structure does the one thing it is best at. The budget is driven by cheap O(1) pre-rolled sums; correctness is enforced by processor-local dedup and idempotent upserts; exactly-once pages ride on a relational CAS; and determinism is guaranteed by a replayable raw log. It is a streaming aggregation platform, not a database, because the workload is fold-events-into-windows, not query-rows.
Bottlenecks & Scaling
Where it breaks first, in order, and the fix for each:
1. Dedup state size and throughput (the number-one pressure point). ~900M in-flight event_ids at 1.5M/sec; an exact set of every id is a memory bomb and a per-event lookup is on the hot path.
Fix: bounded dedup window (ids evicted after ~10-15 min), partition-local dedup (dedup by slo_id partition so it is a local lookup, no distributed coordination), and a rotating Bloom/cuckoo pre-filter so definite-misses skip the exact store. Dedup is the correctness linchpin, so it is engineered first.
2. Hot SLO / hot partition. A few SLOs do 100K+ events/sec, concentrating load and dedup state on one processor instance (because events are partitioned by slo_id).
Fix: sub-partition a hot SLO by hashing event_id into N sub-partitions, each with its own processor and bucket shard, then sum the N sub-buckets when sealing the minute. Dedup stays correct because a given event_id hashes to a fixed sub-partition (so all its duplicates land together). This is the controlled split of a hot key.
3. Write throughput of the aggregation pipeline (~1.5-3M events/sec). No single stream processor sustains the firehose.
Fix: partition the event log by slo_id and run one processor per partition, scaling horizontally by adding partitions/instances. The durable Kafka buffer absorbs spikes and decouples ingest from processing so a slow processor never blocks a producer.
4. Read cost of windowed queries. Alert evaluation and dashboards must not scan raw events. Fix: pre-rolled rolling window sums maintained add-new/subtract-old on the write path, making every budget/burn-rate read O(1). The queried data set is tiny (~13 GB) and cacheable.
5. Alert evaluation falling behind. 10,000 SLOs x multiple tiers on a tight loop could contend with dashboards.
Fix: a dedicated, sharded evaluator fleet reading only O(1) pre-rolled sums, isolated from the dashboard read path, scaling with SLO count. Evaluation cost is bounded by SLOs * tiers, independent of event volume or retention.
6. Double-pages and page storms. A replicated evaluator and a condition that stays true for an hour cause repeated/duplicate pages.
Fix: a per-episode state machine plus a durable CAS firing record keyed by (slo_id, tier, episode_id) - exactly one notification per episode even across replicas and restarts, with the short-window gate auto-resolving and small hysteresis damping flaps.
7. Silent miss - the budget drains and nobody is paged. The evaluator dies, or a bug stops evaluating one SLO. Fix: per-SLO heartbeats and a dead-man’s-switch meta-monitor that pages if any SLO has not been evaluated within N intervals, plus episode state re-derived from the durable store on restart so no transition is lost. The watcher is watched.
8. Late and out-of-order events corrupting the budget. An event’s event-time bucket has already been sealed and its rolling sums rolled forward. Fix: a grace period before sealing a bucket, and for genuinely late events a bounded recompute of the affected rolling sums - the determinism requirement means we correct the number rather than drop the event (the opposite of a best-effort metrics system).
9. SLO definition change or classification bug invalidates past counts. The meaning of “good” changed; historical buckets are now wrong. Fix: the replayable raw event log - re-run the processor from an offset to recompute buckets deterministically under the new definition, versioned so old and new coexist during the switch. This is why raw events are retained 35+ days.
10. The platform’s own availability during an incident. Load and duplicate deliveries spike exactly when the budget is burning, and if the platform is down you burn it unseen. Fix: replicate the ingest and evaluation paths, isolate alerting from dashboard load, reserve headroom for the ~2x spike, and keep the alert path driven off durable state so a failover resumes mid-episode. The alerting path is engineered to be more available than the services it watches - degrade dashboards before you ever degrade the pager.
Wrap-Up
The trade-offs that define this design:
- Exactly-once counting over approximate speed. Unlike a raw metrics pipeline that tolerates dropped samples, the budget drives go/no-go decisions, so we enforce deterministic deduplication (stable source ids, partition-local exact dedup, idempotent upsert folds) and pay the dedup-state cost to make the number true and reprocessable.
- Write-time materialization over read-time scans. We fold every event into fixed 1-minute buckets and maintain rolling sums for every window we will ever query, trading a fixed per-minute aggregation cost and ~13 GB of state for O(1) reads - because scanning billions of raw events per burn-rate read is impossible and alert evaluation must stay real-time.
- Burn rate over remaining-budget thresholds. We alert on the derivative across multiple windows with a short-window confirmation gate, turning the lagging 28-day ratio into a leading indicator that is both fast enough to catch an outage in minutes and quiet enough to be trusted, with a tier and an action per severity.
- Durable per-episode records over stateless firing. Exactly-once pages ride on a relational compare-and-set keyed by episode, not on any process’s memory, so firing holds across replicas, restarts, and failovers - and a dead-man’s-switch meta-monitor guarantees no exhaustion is silently missed.
- A replayable raw log over trusting live counts. Retaining raw events lets us recompute deterministically when a definition changes or a bug is found, buying auditability and correctness at the cost of cold storage - the right trade when the number is reported to stakeholders.
One-line summary: a partitioned event log feeding stateful stream processors that deduplicate by stable event id and fold outcomes into exactly-once 1-minute buckets, a count store materializing rolling multi-window good/total sums so every budget and burn-rate read is O(1), and a sharded multi-window multi-burn-rate evaluator firing exactly once per episode off a durable CAS record with a dead-man’s-switch behind it - trading dedup cost and write-time aggregation for a budget that is correct, fresh to the sub-minute, and pages in minutes before the month’s budget is gone.
Comments