Building Observability for Sub-5-Minute Error Budgets
System DesignModel answerLast updated
Design a monitoring and reliability system that protects a 99.99% availability target for a high-traffic SaaS platform handling 100k requests/second.
Context
You're working on a large-scale SaaS application serving enterprise customers—think project management, document collaboration, or similar workloads. A handful of critical services (issue management, authorization, live updates) must deliver 99.99% availability measured over rolling 30-day periods. This leaves roughly 4.3 minutes per month for any downtime or severely degraded responses.
Your task is to architect the observability and reliability infrastructure needed to consistently hit this target in production.
What You Need to Design
Build a monitoring system and reliability layer that:
-
Defines measurable service health. Pick concrete metrics (SLIs) and thresholds (SLOs) tied to user experience. Base these on industry-standard observability dimensions: request success rate, response time, throughput, and resource usage.
-
Alerts before catastrophe. Configure alerts that fire early enough for intervention, balancing speed of detection against noise. Calculate how quickly different failure modes consume your monthly budget and set alert thresholds accordingly.
-
Isolates failure impact. Ensure that a problem in one dependency (external API, database, cache layer) doesn't cascade and violate the top-level availability promise. Design fault boundaries and fallback strategies.
-
Automates common recovery. For predictable failure patterns—overload, partial outages, bad deployments—trigger automatic remediation without waiting for humans.
-
Validates resilience continuously. Establish a testing regime (chaos experiments, canary rollouts, synthetic probes) that proves your recovery mechanisms actually work under realistic conditions.
Scale and Constraints
- Traffic volume: 100,000 requests per second spread across three geographic regions.
- Telemetry lag: Metrics must flow from application to queryable alert rules in under 15 seconds.
- Monitoring independence: The observability stack should not share critical infrastructure (clusters, accounts, network paths) with the services being monitored.
Areas to Address
- Metric collection pipeline: agents, transport, aggregation, storage, and query evaluation architecture.
- SLI and SLO definitions with concrete numbers; error budget calculations and multi-window burn-rate alert logic.
- Architectural patterns for containing failures: circuit breakers, request hedging, capacity isolation, traffic shaping.
- Rollback automation and chaos validation frameworks.
Provide a structured design covering these components, including trade-offs and failure modes.
Hints
Hint 1
Start with the math: how many failed requests or minutes of downtime does 99.99% allow per month? How fast does a complete outage burn through that budget?
Hint 2
Design alerts using multiple time windows—one for statistical confidence, one for fast reset after recovery—to avoid both missed incidents and alert storms.
Hint 3
Treat response latency as part of availability: a request that times out or takes 10 seconds is effectively a failure from the user's perspective.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer: Observability for 99.99% Availability
1. Understand the Error Budget
Before designing anything, do the arithmetic. It drives every subsequent choice.
Time-based budget: 30 days = 43,200 minutes. Allowing 0.01% downtime gives 4.32 minutes per month. A total outage burns this in about 4 minutes.
Request-based budget: At 100k RPS, a month has roughly 2.6 × 10¹¹ requests. 0.01% failure allowance = ~26 million failed requests per month.
Critical insight: No human can get paged, diagnose, and deploy a fix in 4 minutes. Detection must happen in seconds, and mitigation must be automated. Engineers handle root cause analysis and long-tail issues, not real-time firefighting.
Clarifications to gather:
- Is availability measured per request or per time interval?
- Measured globally or per tenant/region?
- Do maintenance windows count against the budget?
- Which flows are tier-0? (E.g., "create and view issues" counts; "export to CSV" does not.)
2. Define SLIs and SLOs
Measure at the entry point (load balancer or API gateway), as close to the user as possible, segmented by region and endpoint type.
The Four Golden Signals
| Signal | SLI Definition | SLO Target |
|---|---|---|
| Errors | Fraction of valid requests that succeed. Count 5xx responses, timeouts, and malformed replies as failures. Exclude client errors (4xx). | ≥ 99.99% success |
| Latency | Fraction of requests completing under a threshold (e.g., reads < 300ms, writes < 800ms). Requests exceeding 2 seconds count as errors. | ≥ 99.9% under threshold; >2s treated as failure |
| Traffic | Requests per second per cell/region versus baseline. | No SLO; used for anomaly detection and normalizing ratios |
| Saturation | CPU, memory, connection pools, DB lag. | Alert at 70% of capacity; leading indicator only |
Why latency matters: A service that's "up" but responds in 10 seconds is effectively down for users. Requests over 2s degrade both the latency SLO and the error-rate SLO.
3. Burn-Rate Alerting
Burn rate = (observed error rate) / (SLO allowance). Consuming X% of budget in window W gives burn rate = X × (720 hours / W).
Configure multi-window alerts to balance fast detection with low false-positive rates:
| Severity | Budget Used | Long Window | Burn Rate | Error Threshold | Short Window |
|---|---|---|---|---|---|
| Critical + auto-mitigate | 2% | 1 hour | 14.4 | 0.144% | 5 min |
| Page on-call | 5% | 6 hours | 6 | 0.06% | 30 min |
| Create ticket | 10% | 3 days | 1 | 0.01% | 6 hours |
How it works: An alert fires only when both windows exceed their threshold. The long window ensures statistical significance; the short window allows rapid reset after recovery, reducing alert fatigue.
Fast-burn tier: Add a rule for catastrophic failure—burn rate ≥ 100 over 1-minute and 10-second windows. This catches complete outages in ~20–30 seconds and triggers immediate automated rollback or traffic drain.
Low-traffic caveat: For cells with low RPS, require a minimum request count before evaluating, or aggregate small cells to avoid ratio noise.
4. Metric Pipeline Architecture
Target: < 15 seconds from event emission to alert evaluation.
Application (OpenTelemetry SDK, exponential histograms)
↓
Node agent (pre-aggregate every 5s, drop high-cardinality labels)
↓
Regional Kafka cluster (monitoring-owned)
↓
Stream processor (Flink: per-cell/endpoint rollups, SLI counters)
↓
Time-series DB (Mimir/Thanos/VictoriaMetrics, replicated, 10s resolution)
↓
Alert rules (evaluated every 10s) → Alertmanager / mitigation controller
Latency breakdown: ~5s flush + 2s transport + 3s aggregation + 5s evaluation ≈ 15s total.
Key design choices:
- Pre-aggregation at the agent: Reduces 100k events/sec into a bounded set of time series before network transport.
- Histograms over averages: Histograms preserve p99 and allow threshold-based SLI calculations across distributed aggregators.
- Cardinality control: Never use tenant IDs or request IDs as metric labels. Use sampling and traces for high-cardinality debugging.
- Write-ahead buffering: Agents buffer locally to survive transient Kafka failures.
Monitoring Independence
- Run the observability stack in separate cloud accounts, clusters, networks, and identity providers from production.
- Cross-region validation: Region A's SLOs are also evaluated from region B's monitoring cluster.
- Dead-man's switch: Send periodic heartbeats to an external paging provider. If no heartbeat arrives in 60s, that itself triggers a page.
- Maintain static, out-of-band runbooks and break-glass access credentials.
5. Reliability Architecture
Cell-Based Blast Radius Control
Partition each region into N independent cells (full stack: app, cache, DB shard). Assign tenants to cells via consistent hashing with shuffle sharding, so a problematic tenant affects only ~1/N of the customer base.
Deploy changes cell-by-cell. A failure in one cell burns only a fraction of the global error budget, and traffic can shift to healthy cells.
Dependency Classification
Hard dependencies (permissions service, primary database):
- Strict timeouts and multi-AZ replication.
- Local caching with short TTLs (e.g., 10–60s for permissions).
- Cache-hit-only fallback mode: serve recently cached grants, deny unknown requests.
Soft dependencies (search suggestions, avatars, third-party integrations):
- Serve stale cached data.
- Hide UI widgets gracefully.
- Queue writes asynchronously; surface errors only if queues fill.
Per-Request Protections
- Deadline propagation: Each request carries a remaining deadline; intermediate services timeout at (deadline - margin).
- Circuit breakers per dependency per cell: open at >50% failure rate over 10s with ≥20 calls. Half-open after exponential backoff with jitter.
- Bulkheads: Separate thread and connection pools per dependency, preventing slow third-party APIs from exhausting DB connections.
- Retry budgets: Cap retries at 10% of total requests; exponential backoff with jitter; never retry at multiple layers.
- Adaptive concurrency limits + priority shedding: Use AIMD or gradient-based concurrency control. Shed load in order: background sync → bulk exports → non-critical reads → tier-0 writes (last resort).
6. Automated Mitigation
A control-plane mitigation controller subscribes to alerts and executes bounded playbooks:
| Trigger | Action |
|---|---|
| Fast burn + recent deploy (change event within 30 min) | Automated rollback |
| Single-cell burn | Drain cell traffic to healthy cells (if capacity allows) |
| Regional burn | Global load balancer shifts traffic to other regions (requires N+1 capacity) |
| Circuit breaker open | Activate feature flags for degraded mode |
| Saturation alarm | Horizontal scale-out; raise load-shedding threshold |
Safety guardrails:
- All actions are idempotent and rate-limited (e.g., drain max one cell per 5 minutes).
- Post-action verification: confirm burn rate drops within a fixed window (e.g., 5 minutes). Escalate to humans if verification fails.
- Never cascade multiple high-risk actions without human approval.
7. Continuous Validation
Progressive Deployment
- Deploy to 1% canary in one cell.
- Expand to full cell.
- Roll out to one region.
- Go global.
At each stage, automated statistical comparison (Mann-Whitney for latency, proportion tests for errors) gates promotion. Bake time at each stage allows latent issues to surface.
Chaos Engineering
Run automated chaos experiments in production (isolated cells) and staging:
- Kill service instances.
- Inject latency or errors into dependencies.
- Saturate resources (CPU, connections).
- Partition networks between cells.
Measure: Time to detect (TTD), time to mitigate (TTM), and blast radius (requests/minutes affected). Set targets: TTD < 30s, TTM < 3 min for automated playbooks.
Run experiments continuously (weekly in staging, monthly in prod) to verify that circuit breakers, retries, and fallback logic behave as designed.
Synthetic Monitoring
Deploy synthetic probes from external vantage points that mimic real user journeys every 30 seconds. These provide an independent signal and catch issues that internal metrics might miss (DNS, TLS, CDN).
8. Trade-Offs and Common Pitfalls
- Over-aggregation: Aggregating metrics too early loses visibility into tail latencies and per-tenant issues. Use sampling and exemplars (traces linked to metrics) to debug.
- Alert fatigue: Too many low-severity alerts train engineers to ignore pages. Reserve pages for budget-threatening burns only.
- Monitoring as a single point of failure: If observability shares fate with production, you go blind during outages. Maintain strict independence.
- Testing in isolation: Chaos tests that only kill single instances may miss multi-hop cascades. Test realistic failure combinations.
Summary
Sustaining 99.99% availability requires:
- Quantitative SLIs tied to user experience, measured at the edge.
- Multi-window burn-rate alerts that detect issues in seconds.
- Blast-radius isolation via cells, circuit breakers, and bulkheads.
- Automated mitigation for common failure modes.
- Continuous chaos validation to ensure recovery mechanisms work under real conditions.
The goal isn't zero failures—it's constraining failures to stay within a 4-minute-per-month budget through fast detection, automated response, and architectural resilience.