DevOps & Kỹ Thuật Độ Tin Cậy Hệ Thống

Công Cụ Tính Ngân Sách Lỗi & Tốc Độ Tiêu Hao SLO

Mô phỏng tốc độ tiêu hao ngân sách lỗi (Error Budget) theo chuẩn Google SRE. Tính toán downtime cho phép và xuất mã cấu hình cảnh báo Prometheus & Grafana PromQL chuẩn production.

SLO Parameters

99.9%

~1296.0M total requests in 30 days

0.25%
0% (Perfect)2.5%5.0% (Severe)
Error Budget
0.100%
1,295,999 allowed bad requests
Max Downtime
0h 43m 11s
Total allowed outage in 30d
Burn Rate
2.5x
Exhausts budget in 11d 23h

Google SRE Multi-Window Multi-Burn-Rate Matrix

Eliminates alert fatigue by requiring both short and long rolling windows to exceed the burn rate threshold.

Target: 99.9%
Alert SeverityBurn MultiplierLong WindowShort WindowBudget Impact
Critical (Page)14.4x1h5m2% budget in 1 hour
High (Page)6x6h30m5% budget in 6 hours
Medium (Ticket)3x1d2h10% budget in 3 days
Low (Log)1x3d6h10% budget in 3 days
groups:
  - name: checkout-api-slo-burn-rate-alerts
    rules:
      # Critical Page (Fast Burn) (2% budget in 1 hour)
      - alert: checkout_api_SLOBurnRate_14_4x
        expr: |
          (
            rate(http_requests_total{status=~"5.."}[1h])
            /
            rate(http_requests_total[1h])
          ) > (14.4 * 0.00100)
          and
          (
            rate(http_requests_total{status=~"5.."}[5m])
            /
            rate(http_requests_total[5m])
          ) > (14.4 * 0.00100)
        for: 2m
        labels:
          severity: critical
          slo_target: "99.9%"
          service: "checkout-api"
        annotations:
          summary: "High error budget burn rate (14.4x) for checkout-api"
          description: "Service checkout-api is burning its 30-day error budget at 14.4x (threshold: >0.01440). Consuming 2% budget in 1 hour."

      # High Severity Page (Moderate Burn) (5% budget in 6 hours)
      - alert: checkout_api_SLOBurnRate_6x
        expr: |
          (
            rate(http_requests_total{status=~"5.."}[6h])
            /
            rate(http_requests_total[6h])
          ) > (6 * 0.00100)
          and
          (
            rate(http_requests_total{status=~"5.."}[30m])
            /
            rate(http_requests_total[30m])
          ) > (6 * 0.00100)
        for: 2m
        labels:
          severity: critical
          slo_target: "99.9%"
          service: "checkout-api"
        annotations:
          summary: "High error budget burn rate (6x) for checkout-api"
          description: "Service checkout-api is burning its 30-day error budget at 6x (threshold: >0.00600). Consuming 5% budget in 6 hours."

      # Medium Ticket (Slow Burn) (10% budget in 3 days)
      - alert: checkout_api_SLOBurnRate_3x
        expr: |
          (
            rate(http_requests_total{status=~"5.."}[1d])
            /
            rate(http_requests_total[1d])
          ) > (3 * 0.00100)
          and
          (
            rate(http_requests_total{status=~"5.."}[2h])
            /
            rate(http_requests_total[2h])
          ) > (3 * 0.00100)
        for: 2m
        labels:
          severity: warning
          slo_target: "99.9%"
          service: "checkout-api"
        annotations:
          summary: "High error budget burn rate (3x) for checkout-api"
          description: "Service checkout-api is burning its 30-day error budget at 3x (threshold: >0.00300). Consuming 10% budget in 3 days."

      # Low Warning (Drift) (10% budget in 3 days)
      - alert: checkout_api_SLOBurnRate_1x
        expr: |
          (
            rate(http_requests_total{status=~"5.."}[3d])
            /
            rate(http_requests_total[3d])
          ) > (1 * 0.00100)
          and
          (
            rate(http_requests_total{status=~"5.."}[6h])
            /
            rate(http_requests_total[6h])
          ) > (1 * 0.00100)
        for: 2m
        labels:
          severity: warning
          slo_target: "99.9%"
          service: "checkout-api"
        annotations:
          summary: "High error budget burn rate (1x) for checkout-api"
          description: "Service checkout-api is burning its 30-day error budget at 1x (threshold: >0.00100). Consuming 10% budget in 3 days."

Why Single-Window Burn Rate Alerts Fail in Production

Traditional alerts check a single rolling window (e.g. 5 minutes). If a brief traffic spike causes 50 errors in 1 minute, a 5-minute alert fires and wakes up the engineer, even if the system has already recovered. Conversely, a 30-day alert takes days to notice a severe 5% regression.

Google SRE’s Multi-Window Multi-Burn-Rate methodology requires that both a short window (e.g. 5 minutes) and a long window (e.g. 1 hour) simultaneously breach the burn rate threshold. This guarantees near-zero alert reset latency while completely eliminating false positives from ephemeral network blips.

Hướng dẫn sử dụng

  1. Bước 1: Chọn mục tiêu Service Level Objective (SLO, ví dụ 99.9% hoặc 99.95%) và chu kỳ đo lường (ví dụ 30 ngày).
  2. Bước 2: Nhập lưu lượng truy cập trung bình (RPS) để tính số lượng request lỗi tối đa cho phép.
  3. Bước 3: Mô phỏng tỷ lệ lỗi hiện tại để xem hệ số Burn Rate Multiplier và thời gian cạn kiệt ngân sách.
  4. Bước 4: Sao chép cấu hình Prometheus Alertmanager YAML hoặc truy vấn PromQL để tích hợp vào hạ tầng giám sát.

Câu hỏi thường gặp

Cảnh báo Multiwindow Multi-Burn-Rate là gì?
Đây là tiêu chuẩn vàng của Google SRE để theo dõi SLO. Hệ thống giám sát đồng thời hai cửa sổ thời gian: cửa sổ dài (ví dụ 1 giờ) và cửa sổ ngắn (ví dụ 5 phút). Cách này giúp loại bỏ cảnh báo rác do các đợt tăng đột biến tạm thời (alert fatigue), đồng thời phát hiện tức thì sự cố nghiêm trọng.
Hệ số Burn Rate Multiplier được tính như thế nào?
Burn Rate là tỷ số giữa tỷ lệ lỗi quan sát thực tế và tỷ lệ lỗi tối đa cho phép. Với SLO 99.9%, tỷ lệ lỗi cho phép là 0.1%. Nếu hệ thống gặp tỷ lệ lỗi 1.44%, hệ số burn rate là 1.44 / 0.1 = 14.4x, làm tiêu hao 2% ngân sách tháng chỉ trong 1 giờ.
Thời gian downtime cho phép của SLO 99.9% so với 99.99% là bao nhiêu?
Trong chu kỳ 30 ngày, SLO 99.9% cho phép tối đa 43 phút 12 giây ngừng hoạt động. Trong khi đó, SLO 99.99% ("bốn số 9") chỉ cho phép tối đa 4 phút 19 giây downtime cho toàn bộ tháng.
Tại sao nên cảnh báo theo Burn Rate thay vì số lượng lỗi 500 hay CPU thô?
Ngưỡng tĩnh (như "lỗi 500 > 100") thường xuyên báo động giả trong các đợt traffic cao ngay cả khi tỷ lệ thành công là 99.99%, hoặc không kích hoạt vào ban đêm khi lưu lượng thấp dù 100% người dùng gặp lỗi. Cảnh báo theo Burn Rate phản ánh chính xác mức độ ảnh hưởng thực tế tới trải nghiệm người dùng và hoạt động kinh doanh.

The Senior Full-Stack Production Kit (2026)

Checklists, Docker recipes, and SSR error fixes in one dense PDF.

Get Free Kit

Bài viết liên quan