ENع
→SLOs
الدرس 19 · التشغيل

SRE: SLOs and error budgets

لم يُترجم بعد؛ يُعرض باللغة الإنجليزية

14 دقيقة9 خطوات5 أسئلةAdvanced
عن هذا الدرس

Site reliability engineering (SRE) does not chase 100%. It measures what users feel with an SLI, sets a target for it with an SLO, and treats the gap, 1 − SLO, as an error budget the team may spend. Follow one service through a 30-day window: 99.9% leaves 1,000 failed requests to spend, a bad release burns them 14.4 times too fast and pages the on-call engineer, and when the budget hits zero an agreed policy freezes feature releases.

ستتعلّم

حدّد ما تشعر بأنك أتقنته. هذا التقييم الذاتي لا يؤثر في درجة الدرس.

شكل 19 · تفاعلي
01 / 09

Why not 100%?

Site reliability engineering (SRE) runs services the way software engineers would. Its first lesson: 100% reliable is the wrong target. A user on a 99% reliable phone cannot tell 99.99% from 99.999%, and each extra nine costs far more.

users feel the weakest link:
  phone, Wi-Fi, mobile network, your service

99.9%    one nine more   99.99%   99.999%
each extra nine can cost ~100x more (SRE book)

so: choose a target on purpose
جارٍ تحميل الرسم…
أو ← →
اقرأ الدرس خطوة بخطوة
  1. Why not 100%?

    Site reliability engineering (SRE) runs services the way software engineers would. Its first lesson: 100% reliable is the wrong target. A user on a 99% reliable phone cannot tell 99.99% from 99.999%, and each extra nine costs far more.

    users feel the weakest link:
      phone, Wi-Fi, mobile network, your service
    
    99.9%    one nine more   99.99%   99.999%
    each extra nine can cost ~100x more (SRE book)
    
    so: choose a target on purpose
  2. SLI: count the good

    A service level indicator (SLI) measures what users feel: good events divided by all events. Here a request is good if it is answered correctly and fast enough. The counter keeps that running share.

    SLI = good events / all events
    
    good request: right answer (not HTTP 5xx)
                  and fast enough (say < 300 ms)
    
    total, bad = 200_000, 600
    sli = 1 - bad / total      # 0.997 on day 6
  3. SLO: set the target

    A service level objective (SLO) is a target for an SLI over a time window. Ours: 99.9% of requests good over a rolling 30 days. An SLA is a contract with penalties, usually looser than the SLO.

    slo = 0.999        # SLO: 99.9% good
    window: the last 30 days, rolling
    
    SLI  what you measure      99.7%
    SLO  what you aim for      99.9%
    SLA  what you promise, with penalties
         (usually looser than the SLO)
  4. The error budget

    The error budget is 1 − SLO: the failures you may have. 0.1% of the 1,000,000 requests expected in 30 days is 1,000 bad requests, ten blocks of 100. In time, it is 43.2 minutes of full outage.

    error budget = 1 - SLO = 0.1%
    
    budget = round(1e6 * (1 - slo))   # 1000
    in time: 30 d x 24 h x 60 min x 0.001
           = 43.2 minutes down per 30 days
    
    a budget is for spending: releases, experiments
  5. Burning on pace

    Days 1 to 3: normal releases, 100 failed requests. 10% of the budget is gone after 10% of the window. That ratio is the burn rate. At 1.0 the budget lasts exactly 30 days, so the team keeps shipping.

    day 3 of 30     100 bad of 100,000
    
    burn rate = budget used / window used
              = 10% / 10% = 1.0
    
    1.0 -> the budget ends with the window
    SLI so far 99.90%: right on target
  6. A bad release pages

    Day 4: a release passes the open gate and breaks checkout. In one hour 2% of the budget burns, a burn rate of 14.4. Google's SRE workbook suggests paging at exactly this point: an urgent alert wakes the on-call engineer now.

    day 4, first hour: 20 bad of ~1,389
    
    error rate 1.44% / 0.1% allowed = 14.4
    14.4 for 1 h = 2% of the budget
    
    SRE workbook, alerting on SLOs:
      2% in 1 h  (14.4)  page
      5% in 6 h  (6)     page
      10% in 3 d (1)     ticket
  7. Burn rate 3

    By day 6, 600 requests have failed: 60% of the budget in 20% of the window, a burn rate of 3.0. That equals the error rate, 0.3%, over the 0.1% allowed. At 3× a 30-day budget lasts 10 days.

    day 6 of 30     600 bad of 200,000
    
    left = budget - bad            # 400
    burn = round((1 - sli) / (1 - slo), 1)
                                       # 3.0
    
    60% / 20% = 0.3% / 0.1% = 3.0
    budget lasts 30 / 3 = 10 days
  8. Budget spent: freeze

    Days 7 to 10: the fix is slow and failures continue at 3×. On day 10 the budget hits zero, as predicted. The team's error budget policy kicks in: feature releases stop until the service is back within its SLO.

    day 10 of 30    1,000 bad of 333,333
    budget left: 0
    
    error budget policy (SRE workbook):
      halt changes and releases
      except urgent fixes and security fixes
      until the service is back within its SLO
  9. One number, shared

    Fixes and security patches still pass the gate. Product, developers and SREs agreed this policy in advance, so no one argues mid-incident. One shared number decides: budget left, ship faster; budget gone, work on reliability.

    fix -> passes the gate, errors stop
    feature -> waits
    
    policy agreed before any incident
      by product, developers and SREs
    
    budget left  -> ship faster, take risks
    budget gone  -> spend time on reliability

اختبار يتاح بعد الخطوة الأخيرة.