SRE Practices
Error Budgets
An SLO of 99.9% availability is also a permission: the service may fail 0.1% of the time. That allowance is the error budget, and it turns the eternal argument between shipping features and protecting stability into a shared, measurable decision.
Calculate the Budget
For a request-based SLO, the budget is the number of requests allowed to fail in the window. With a 99.9% SLO over 30 days and 50 million requests, the budget is 50,000 failed requests. For a time-based SLO, 99.9% over 30 days allows 43.2 minutes of unavailability (see the table in TechOps Fundamentals). Track the remaining budget continuously and show it on the service dashboard.
Agree on a Budget Policy
The budget only works if everyone agrees in advance what happens when it runs low. A typical written policy:
- Budget healthy: release normally; spend budget on planned risk such as experiments, migrations and chaos tests.
- Budget below 25%: releases need extra review; reliability work moves up in priority.
- Budget exhausted: freeze non-urgent feature releases until the service is back within SLO; the team works on the causes found in recent postmortems.
The policy is agreed by product and engineering leadership together, so a freeze is a pre-agreed rule, not a fight during a bad week. If the budget is never touched, the SLO may be stricter than users need, and the team can move faster.
Toil Reduction
Google's SRE book defines toil as operational work that is manual, repetitive, automatable, tactical, without enduring value, and that grows linearly with the service. Restarting a stuck process every week, resizing disks by hand and copying data between systems on request are toil; designing an alert or writing a postmortem are not.
Measure It
Toil is easy to underestimate because each instance is small. Ask the team to log toil for a few weeks: the task, how often, and how long it took. Google aims to keep each SRE's toil below 50% of their time, so at least half remains for engineering that makes the service better. A team spending most of its time on interrupts cannot improve the system that causes them.
Eliminate It
Rank toil by total time per month and attack the top of the list. The best fix removes the need entirely (fix the leak instead of automating the restart); the next best is self-service (let teams create databases through a pipeline instead of a ticket); then automation (a script or controller that does the task, as in Shell Automation). Compare the cost of automation against the time saved over a year, including the risk reduction of not doing it by hand at 3 a.m.
Capacity Planning
Running out of capacity is an outage you can see coming. Capacity planning makes sure there is enough headroom for growth, for traffic peaks, and for the loss of a zone, without paying for far more than needed.
Forecast Demand
Combine organic growth — the trend in traffic and data, from months of metrics — with inorganic events: launches, marketing campaigns, seasonal peaks, a large customer onboarding. Express demand in the unit that limits the service, such as requests per second at peak, concurrent connections or stored terabytes.
Know Your Limits
Forecasts are useless without knowing what one instance can handle. Load-test the service on production-like infrastructure until latency breaks the SLO, and note which resource saturates first. Then provision so that the forecast peak fits with an N+1 or N+2 margin: the service still meets its SLO with one instance, or one whole zone, lost. Re-test after significant changes, because a new feature can halve throughput per instance. Use autoscaling for fast, short variations, and planning for the baseline, quotas and anything that takes weeks to obtain.
Designing for Reliability
Most large outages are cascades: one slow dependency ties up threads, retries multiply the load, and healthy services fall over too. A handful of design patterns stops the cascade.
Timeouts and Retries with Backoff
Every network call needs a timeout shorter than the caller's own deadline; without one, a hung dependency hangs you. Retries hide brief failures but can turn a slow dependency into an overloaded one, so retry only idempotent operations, a small number of times, with exponential backoff and random jitter so that thousands of clients do not retry in synchronized waves:
import random
import time
class TransientError(Exception):
"""A failure worth retrying: timeout, connection reset, HTTP 503."""
def call_with_retries(operation, attempts=4, base=0.2, cap=5.0):
"""Call operation(); on TransientError retry with capped exponential backoff and full jitter."""
for attempt in range(attempts):
try:
return operation()
except TransientError:
if attempt == attempts - 1:
raise # out of attempts: let the caller decide
delay = random.uniform(0, min(cap, base * 2 ** attempt)) # "full jitter"
time.sleep(delay)
Limit retries at one layer only. If the browser, the gateway and three services each retry three times, one user click can become hundreds of requests to the struggling database.
Circuit Breakers and Load Shedding
A circuit breaker watches calls to a dependency; when failures exceed a threshold, it “opens” and fails calls immediately for a while instead of waiting on timeouts, then lets a few test calls through to check for recovery. This protects the caller's resources and gives the dependency room to recover. Load shedding applies the same idea to incoming traffic: when a service is saturated, rejecting some requests quickly (with HTTP 429 or 503) keeps latency acceptable for the rest, instead of every request timing out.
Redundancy and Graceful Degradation
Remove single points of failure by running more than one instance of everything in the critical path, across failure domains, as discussed in Cloud Operations and Replication & HA. Then decide what the service does when a non-critical dependency is down: show cached recommendations, hide the reviews panel, queue the confirmation e-mail. A shop that cannot show “customers also bought” should still take orders. Design these fallbacks deliberately, and test them, because untested fallbacks usually fail too.
Reliability as a Practice
SRE is less a job title than a set of habits that make reliability continuous rather than a reaction to the last outage.
Production Readiness and Launch Reviews
Before a new service takes production traffic, review it against a readiness checklist: defined SLOs, dashboards and alerts with runbooks, tested rollback, capacity tested for launch traffic, dependencies and their failure modes documented, on-call ownership agreed. The review is a conversation that improves the design, not a gate to pass with paperwork.
Test Failure Deliberately
Chaos engineering runs controlled experiments that inject failure — kill an instance, add latency to a dependency, block a zone — to verify that the system behaves as designed. Start with a hypothesis (“checkout stays within SLO if one of three instances dies”), run it in staging, keep the blast radius small, and have a way to stop immediately. Each experiment that finds a weakness has just prevented a future incident.
Practice Lab
Use a service you built in an earlier lab, or a small web application with one dependency you can slow down or stop.
Define a Budget and a Policy
- Choose an availability SLO and calculate the 30-day error budget both in minutes and in failed requests at your traffic level.
- Write a one-page error budget policy with actions for healthy, low and exhausted budgets.
- Log your own toil for one week of operating the service, rank it, and automate or eliminate the top item.
Make a Service Resilient
- Add a 2-second delay to the dependency and observe what happens to your service with no timeout configured.
- Add a timeout, retries with backoff and jitter, and a fallback response, then repeat the experiment and compare latency and errors.
- Load-test until the SLO breaks, record the saturating resource, and compute how many instances you need for twice today's peak with one instance lost.