Skip to main content

SRE Practices

Master Site Reliability Engineering to build and operate reliable, scalable, and efficient systems.

What is Site Reliability Engineering?โ€‹

Site Reliability Engineering (SRE) is an engineering discipline focused on building, maintaining, and evolving systems that are reliable, scalable, and efficient. SRE applies software engineering principles to operations.

SRE Principlesโ€‹

  1. Reliability is a Feature โ€” Reliability is not an afterthought but a primary requirement
  2. Operations as Software Engineering โ€” Use code automation for operational tasks
  3. Measure Everything โ€” Quantify reliability and use data to make decisions
  4. Embrace Risk โ€” Not all reliability is good (cost trade-off)
  5. Sustainable Operations โ€” Operations should be sustainable, not burnout-inducing

SRE Cultureโ€‹

  • Blameless postmortems โ€” Learn from failures without blaming individuals
  • Collaboration โ€” Development and operations work together
  • Automation โ€” Reduce toil through automation
  • On-call sustainability โ€” On-call work is sustainable, not a punishment
  • Learning and growth โ€” Invest in team development and skills

SLOs, SLIs, and SLAsโ€‹

The three pillars of SRE reliability measurement.

SLI (Service Level Indicator)โ€‹

An SLI is a specific, measurable characteristic of service performance. It's what you actually measure.

Examples:

  • Percentage of requests successfully completed (success rate)
  • Percentage of requests completing within latency < 200ms
  • Percentage of uptime (availability)
  • Error rate
  • Data freshness (for data pipelines)
  • Throughput (requests per second)

Good SLI Properties:

  • Directly related to user experience
  • Measurable and quantifiable
  • Easy to collect data
  • Reflects what users care about

SLO (Service Level Objective)โ€‹

An SLO is a target value for an SLI. It's the goal you're trying to meet.

Examples:

  • 99% of requests complete successfully
  • 99.9% of requests complete within 200ms
  • 99.99% availability (52 minutes downtime per year)
  • 95% of users experience error rate < 0.5%
  • 99% data freshness (99% of data < 5 minutes old)

Setting SLOs:

  • Based on user expectations
  • Based on business requirements
  • Based on operational constraints
  • Based on cost-benefit analysis

SLA (Service Level Agreement)โ€‹

An SLA is a contractual commitment to users about service levels. Violations can result in penalties.

Example SLA:

"We guarantee 99.95% uptime. If we fall below this, you get 10% credit on monthly bill."

Relationship Between SLI, SLO, SLAโ€‹

SLI: What you measure (99.8% uptime)
SLO: What you target (99.95% uptime)
SLA: What you guarantee (99.95% uptime with penalties)

Typical: SLI < SLO <= SLA
(measured result) < (target) <= (guaranteed)

Error Budgetsโ€‹

An error budget is the maximum amount of errors allowed while still meeting your SLO. It's the inverse of your SLO.

Calculating Error Budgetโ€‹

Error Budget = (1 - SLO) * Total Time

Example:
SLO: 99.9% uptime
Error Budget: (1 - 0.999) = 0.001 = 0.1%
Per month (30 days): 0.001 * 30 * 24 * 60 = 43.2 minutes
Per year: 0.001 * 365 * 24 * 60 = 525.6 minutes (8.7 hours)

Using Error Budgetโ€‹

Principle: Once your error budget is consumed, you stop deploying and focus on stability.

Month: January
SLO: 99.9% (43.2 min error budget)
โ†“
Jan 5: Major outage consumes 30 min
โ†’ Remaining budget: 13.2 min
โ†“
Jan 20: Want to deploy risky feature
โ†’ Risk assessment: 70% chance of issues
โ†’ Not safe with only 13.2 min budget
โ†’ Postpone deployment until next month
โ†“
Month: February
โ†’ Error budget resets
โ†’ Deploy risky feature

Error Budget Policiesโ€‹

Conservative: Only deploy when error budget > 50% Moderate: Deploy when budget > 20% Aggressive: Deploy whenever budget > 0%

Benefits of Error Budgetsโ€‹

  • Aligns incentives โ€” Dev/Ops are motivated by same metric
  • Enables risk-taking โ€” Safe to experiment when budget allows
  • Drives reliability investment โ€” Unreliable features consume budget
  • Fair to all services โ€” Same rules for all teams

Toil and Toil Reductionโ€‹

Toil is the operational work that doesn't add lasting value. It grows with traffic but doesn't improve your system.

Toil Characteristicsโ€‹

  • Manual โ€” Repetitive manual work
  • Automatable โ€” Could be done by a machine
  • Tactical โ€” Reactive rather than strategic
  • Non-value-adding โ€” Doesn't improve reliability
  • Grows linearly โ€” Increases with service size

Examples of Toilโ€‹

  • Manually restarting failed services
  • Responding to the same alert repeatedly
  • Manually scaling systems
  • Manually provisioning servers
  • Copying data between systems by hand
  • Manual backups

Examples of Non-Toil Workโ€‹

  • Building monitoring systems
  • Writing automation scripts
  • Designing disaster recovery procedures
  • Improving system architecture
  • Reducing alert noise
  • Capacity planning

Toil Reduction Strategyโ€‹

Goal: Reduce toil to < 50% of SRE work

SRE Time Allocation:
Toil: 30-50%
On-call: 5-10%
Project work: 30-40%
Training: 5-10%

Approach:

  1. Measure toil โ€” How much time is spent on toil?
  2. Identify toil โ€” What specific tasks are toil?
  3. Automate โ€” Write code to replace manual work
  4. Monitor results โ€” Verify automation worked
  5. Repeat โ€” Continuously reduce toil

Automation Benefitsโ€‹

  • Faster response (machines are faster than humans)
  • No human error
  • Scalable (handle increased load without more people)
  • Free up humans for higher-value work

Incident Managementโ€‹

Effective incident response minimizes customer impact and recovery time.

Incident Severityโ€‹

P1 (Critical): Customer-facing service down or severely degraded

  • Response time: Immediate
  • All hands on deck
  • Example: Authentication service down (99% of users affected)

P2 (High): Significant service degradation but workarounds exist

  • Response time: < 30 minutes
  • Major incident commander
  • Example: Payment processing slow but accepting transactions

P3 (Medium): Minor service issues, low user impact

  • Response time: < 4 hours
  • Assigned to on-call engineer
  • Example: Report generation taking longer than normal

P4 (Low): Cosmetic issues, no user impact

  • Response time: Handle during business hours
  • Can wait for next sprint
  • Example: Typo in error message

Incident Response Processโ€‹

1. DETECTION
- Monitoring alerts
- User reports
- Proactive checks

2. ACKNOWLEDGMENT (P1: < 5 min)
- On-call engineer acknowledges
- Incident commander assigned
- Team assembled

3. INVESTIGATION (P1: 15-60 min)
- Gather information
- Check logs, metrics, traces
- Understand impact scope
- Identify root cause

4. MITIGATION (P1: 15-60 min total)
- Implement temporary fix if needed
- Reduce customer impact
- Prevent further degradation

5. RESOLUTION (varies)
- Apply permanent fix
- Verify systems recovering
- Monitor for side effects

6. COMMUNICATION
- Status updates every 30 min
- Customer-facing communication
- Stakeholder notifications

7. CLOSEOUT
- Incident declared resolved
- Monitoring verified
- Schedule postmortem

On-Call Best Practicesโ€‹

  • On-call shifts: 1-2 weeks, not longer
  • Handoff process: Clear transition between engineers
  • Clear escalation: Who to contact if primary on-call unreachable
  • Tool access: On-call engineer has all necessary access
  • Documentation: Runbooks for common issues
  • Coverage: Never a single point of failure for on-call

Postmortemsโ€‹

Postmortems are structured retrospectives after incidents focused on learning, not blame.

Postmortem Timelineโ€‹

Incident occurs โ†’ 24-72 hours โ†’ Postmortem held โ†’ Weeks โ†’ Review follow-ups

Postmortem Structureโ€‹

1. Incident Summary

  • What happened
  • When it started and ended
  • Customer impact
  • How was it resolved

2. Timeline

14:05 - Alert fired: High error rate
14:07 - On-call acknowledged alert
14:10 - Investigated error logs
14:15 - Identified database connection pool exhaustion
14:25 - Restarted database service
14:35 - Verified system recovered

3. Root Cause Analysis

  • Why did the database connection pool exhaust?
  • Why wasn't this caught earlier?
  • Were there warning signs?

Example Root Cause Chain:

Database connection pool exhausted
โ†‘
Due to: New feature using more connections
โ†‘
Due to: Feature didn't implement connection pooling
โ†‘
Due to: Code review didn't catch this pattern
โ†‘
Due to: No automated check for this pattern

4. Contributing Factors

  • What conditions made this worse?
  • Were there multiple problems?
  • What could have reduced impact?

5. Action Items

  • Add monitoring for connection pool usage
  • Implement linting rule for connection pooling
  • Update code review checklist
  • Load test new features before deployment
  • Update runbook with mitigation steps

Postmortem Principlesโ€‹

  • Blameless culture โ€” Focus on systems, not individuals
  • Psychological safety โ€” People must feel safe speaking up
  • Actionable items โ€” Create concrete improvements
  • Follow-up โ€” Track items to completion
  • Share learnings โ€” Document and share with organization

Capacity Planningโ€‹

Ensuring systems have sufficient resources to handle current and future load.

Capacity Planning Processโ€‹

1. MEASURE
- Current resource usage (CPU, memory, disk, bandwidth)
- Growth rate (requests/day, data growth)
- Peak vs average load

2. FORECAST
- Project future usage
- Account for seasonal peaks
- Plan for growth scenarios

3. PLAN
- When will you hit 70% capacity?
- When will you hit 90% capacity?
- How long to provision new capacity?

4. PROVISION
- Add resources before hitting limits
- Test systems with new capacity
- Verify performance improvement

5. MONITOR
- Track actual vs projected usage
- Adjust forecasts as needed
- Plan next capacity addition

Capacity Metricsโ€‹

  • CPU utilization โ€” Target: < 70% peak, < 50% average
  • Memory utilization โ€” Target: < 80%
  • Disk usage โ€” Target: < 80% (plan for 2x growth)
  • Network bandwidth โ€” Plan for peak load + headroom
  • Database connections โ€” Monitor pool exhaustion

Load Testingโ€‹

Test systems at expected load:

# Simulate 10,000 concurrent users for 1 hour
$ load-test --concurrency=10000 --duration=3600 https://example.com

# Results:
# Average response time: 150ms
# P99 response time: 750ms
# Error rate: 0.01%
# Requests/sec: 8,500

Best Practicesโ€‹

1. Measure Reliabilityโ€‹

  • Define SLIs that matter to users
  • Set realistic SLOs
  • Track error budgets
  • Monitor actual reliability

2. Automate Toilโ€‹

  • Document manual processes
  • Identify candidates for automation
  • Build tools to replace manual work
  • Continuously reduce toil

3. Prevent Incidentsโ€‹

  • Implement comprehensive monitoring
  • Alert on symptoms, not just metrics
  • Build in redundancy and graceful degradation
  • Test failure scenarios regularly

4. Respond Effectivelyโ€‹

  • Have clear incident response process
  • Train team on incident response
  • Use runbooks for common issues
  • Conduct incident drills

5. Learn from Failuresโ€‹

  • Hold blameless postmortems
  • Track action items to completion
  • Share learnings with organization
  • Update systems based on learnings

6. Balance Reliability and Velocityโ€‹

  • Use error budgets to guide deployment decisions
  • Don't over-invest in reliability (cost trade-off)
  • Enable risk-taking when budget allows
  • Make speed and reliability compatible

Exercisesโ€‹

Exercise 1: Define SLOsโ€‹

For a web application, define:

  • Three meaningful SLIs
  • SLOs for each SLI
  • Rationale for each SLO choice
  • Error budget for each

Exercise 2: Root Cause Analysisโ€‹

Given an incident description:

  • Construct timeline of events
  • Identify immediate cause
  • Find root cause through 5 Whys
  • List contributing factors
  • Propose preventative action items

Exercise 3: Capacity Planningโ€‹

For a service with current metrics:

  • Project usage 3, 6, 12 months out
  • Determine when to provision new capacity
  • Plan resource additions
  • Calculate costs of scaling

Exercise 4: Automation Projectโ€‹

Identify toil in your operations:

  • What manual tasks repeat regularly?
  • Which have highest impact if automated?
  • Create plan to automate top 3 tasks
  • Estimate time saved

Exercise 5: Postmortem Facilitationโ€‹

Practice writing and facilitating a postmortem:

  • Write timeline of incident
  • Identify root cause
  • Create action items
  • Present to team without blame

Key Takeawaysโ€‹

  • SRE combines software engineering with operations to build reliable systems
  • SLIs measure what matters, SLOs set targets, and error budgets guide decisions
  • Error budgets align incentives between development and operations
  • Toil reduction frees up humans for higher-value work
  • Effective incident management minimizes customer impact and recovery time
  • Blameless postmortems drive learning and continuous improvement
  • Capacity planning prevents performance degradation under growth
  • Automation and monitoring are critical to SRE success
  • Reliability is a feature requiring intentional design and investment