As asked
Given a 99.9 percent SLO over 28 days, write a function that takes the last hour's success and total request counts and returns the burn rate as a multiple of the budget.
Sample answer outline
Error budget per hour at 99.9 percent over 28 days is 0.1 percent of an hour's request count. Burn rate = (observed_error_rate / 0.001). A burn rate of 1 means you are burning exactly at budget. A burn rate of 14.4 means you will exhaust the budget for the month in the next hour. Common alert thresholds: page on 14.4x over 1 hour (fast burn), 6x over 6 hours (slow burn). The function is small but the framing is what the interviewer is testing.
Reference implementation (typescript)
export function burnRate(
successCount: number,
totalCount: number,
sloTarget = 0.999,
): number {
if (totalCount === 0) return 0;
const errorBudget = 1 - sloTarget;
const observedErrorRate = 1 - successCount / totalCount;
return observedErrorRate / errorBudget;
}Expect these follow-ups
- How would you alert on both fast and slow burn at the same time?
- What is the failure mode if traffic volume drops by 90 percent?
- Why is a single threshold alert worse than a multi-window one?