Latency, Availability, and Error Budgets for APIs

Set API latency and availability objectives, calculate error budgets, and use service level indicators to guide practical reliability trade-offs.

published: reading time: 9 min read author: Geek Workbench updated: November 4, 2026
Quick Summary

SLIs measure user-visible API outcomes, SLOs set targets over a window, and error budgets show the allowed bad events. This guide works through an interactive account-summary route, defines eligible requests and a latency-based good outcome, calculates a weekly budget, and shows what a route-level fast burn should trigger.

Latency, Availability, and Error Budgets for APIs

Introduction

Latency and availability objectives turn customer expectations into measurable service goals. A service level indicator (SLI) states what counts as good, an objective (SLO) sets the target over a window, and an error budget counts how many bad outcomes the target permits.

Define the route and customer journey before choosing a number. A service-wide average can hide a broken endpoint; the account-summary example below keeps the request population visible.

Define a useful SLI

Specify the request population, what counts as good, and the measurement window. A latency SLI usually measures the share of eligible requests that finish within a route-specific limit. Define availability around an outcome that satisfies the API contract, and split out critical routes when an aggregate could hide user impact.

Trade-offs when setting objectives

Reliability choice Benefit Cost or risk Good fit
Tight latency objective Protects responsive user journeys Can drive expensive capacity or caching work Interactive endpoints with clear latency expectations
Loose latency objective Leaves room for lower-cost infrastructure Slow responses may count as successful Background or batch operations
One service-wide SLO Simple to explain and maintain Can hide a failing high-value route behind healthy traffic Small APIs with similar route importance
Route-level SLOs Shows which user journeys need attention Requires enough traffic and more ownership APIs with distinct critical and noncritical operations
Burn-rate alerts Detects rapid budget loss early Can be noisy with small or uneven traffic samples High-traffic services with reliable telemetry
Window-based budget alerts Easy to communicate against a monthly target May react too slowly to a sudden incident Teams that need a simple release-policy signal

Error budgets in practice

An SLI can be expressed as good events divided by eligible events. The error-budget fraction is 1 - SLO, applied to the same event population and window. The Google SRE Workbook’s SLO guidance explains the ratio and budget calculation. The route example below uses the same arithmetic with a product-specific target.

Make the error-budget policy specific

Agree on actions before a budget is nearly gone. When burn is within the expected range, normal releases continue. Fast burn should page an owner who can verify the signal, identify affected routes, and reduce immediate risk. If the budget is exhausted, pause nonessential feature releases and prioritize fixes that restore the SLO. Keep an exception for incident mitigation and urgent security work.

The policy should name who makes the call, which services and routes it covers, and when normal delivery resumes. Use burn rate and user impact together; a small, low-traffic API can have noisy percentages, while an aggregate service budget can hide a critical route. Review the policy after incidents so a budget alert leads to a useful decision rather than a blanket freeze.

Worked example: account-summary route

Suppose a customer dashboard uses GET /v1/accounts/{accountId}/summary for an interactive account view. The product team chooses a 400 ms response limit because this route blocks that view; the value is an example target for this audience, not a general API default. Set and revisit it using customer expectations and measured route behavior.

For this SLI, count customer requests with a valid account ID and request shape after the user is authenticated and authorized for that account. Exclude malformed requests, intentionally denied access, and synthetic probes. Count a timeout, server error, invalid response body, or late response as bad. If authentication itself is part of the customer journey, define a separate SLI for that path rather than silently excluding its failures.

Measure from the dashboard request start until the full response reaches the browser, and record timeouts there. Backend logs can miss requests that never reach the service; the Google SRE Workbook discusses this measurement gap.

An eligible read is good only when the API returns a valid 200 response within 400 ms:

type SummaryResult =
  | {
      kind: "response";
      status: number;
      durationMs: number;
      validPayload: boolean;
    }
  | { kind: "timeout" };

function isGoodSummaryRead(result: SummaryResult): boolean {
  return (
    result.kind === "response" &&
    result.status === 200 &&
    result.validPayload &&
    result.durationMs <= 400
  );
}

Assume this customer-facing route has a 99.5% good-read SLO over a rolling seven-day window and receives 28,000 eligible requests during one such window. Its budget is 28,000 × 0.005 = 140 bad reads. If 175 requests fail or exceed 400 ms, the SLI is 27,825 / 28,000 = 99.375%; the route has used 125% of its budget. Count each request only once, even if it both fails and exceeds the latency limit. These counts and targets illustrate the calculation. A team should set its own objective from the route’s audience and service history.

Now suppose 140 of 1,000 eligible reads in a 30-minute window are bad. That is a 14% bad-event rate. Against the 0.5% budget rate, the burn rate is 14% / 0.5% = 28×. For this interactive route, the team might page when the 30-minute burn rate exceeds 10×, so the on-call can respond before a prolonged slowdown consumes the weekly budget. That threshold is an example policy, not a standard. The route owner checks sample volume and user impact, pauses risky releases, and rolls back a correlated change or applies a known mitigation. The alert-design guide covers signal selection and workload-specific thresholds. The Google SRE Workbook’s SLO alerting guidance explains burn rate as budget consumption relative to the SLO.

When to use an SLI

Use SLIs and SLOs for APIs with meaningful user expectations, shared operational ownership, or frequent reliability trade-offs. Start with a few measures tied to user journeys. Do not set targets before validating telemetry quality, and do not set 100% availability as a practical target for a system with dependencies. A single uptime number can also mislead when an API has routes with different importance.

Common pitfalls

  • Treating every 2xx response as good can count empty, stale, or otherwise unusable results as success. Define good outcomes in terms of the API contract.
  • Reporting only an aggregate SLO lets high-volume routes hide failures on a critical low-volume route. Split out important user journeys when their impact differs.
  • Alerting on total budget consumed alone can miss a sudden outage early in the window. Add a burn-rate signal for fast loss.
  • Changing exclusions after an incident makes historical performance hard to compare and can undermine trust. Version the query and record why its population changed.
  • Using a percentile from too few requests creates unstable conclusions. Choose a window and traffic population that provide enough samples, and show sample counts with the result.

Quick recap

  • Define a route’s eligible request population and one user-visible good outcome.
  • Set latency and SLO thresholds for that route’s audience, then show the budget math.
  • Tie fast-burn alerts to an owner and a response the team can take.

Interview questions

1. How does an SLO differ from an SLA?

An SLO is an internal reliability target. An SLA is a formal external commitment that may define remedies. Teams commonly set the SLO stricter than the SLA to detect risk early.

2. Why use p99 latency instead of average latency?

The average can look good while a small fraction of users experience very slow requests. A high percentile exposes that tail, though it must be computed over enough samples and a well-defined route population.

3. How do you calculate an error budget?

Subtract the SLO from 100% and apply the remaining fraction to the same eligible-event population and time window. Use the result to guide decisions agreed to in the service's policy.

4. What should a team do when its error budget burns quickly?

Confirm the SLI signal, identify the affected routes and user impact, and reduce immediate risk. The response may include slowing risky releases while the team investigates the cause.

5. Why use burn rate as well as total budget consumption?

Total consumption shows how much budget has been spent in the window. Burn rate shows how quickly it is being spent and can reveal an incident early enough for the team to respond.

6. Why can one service-wide SLO hide a reliability problem?

High-volume healthy routes can dominate the aggregate and obscure failures on a lower-volume but more important route. Measure critical user journeys separately when their impact differs.

7. What belongs in an error-budget policy?

Define actions for normal, fast-burn, and exhausted-budget states, name the decision owner, and set criteria for resuming ordinary releases. Include exceptions for urgent mitigation and security work.

8. When should an SLI exclude a request?

Only when the exclusion is part of a documented definition tied to user impact, such as clearly identified health checks. Keep the population stable and record changes so historical results remain comparable.

Further reading

Conclusion

A budget is useful only when someone acts on its signal. Keep the request population stable, review what customers experienced, and record why an objective changes so the new target does not rewrite the old measurement.

Category

Related Posts

Network Observability: Signals for Reliable Services

Track network health across hosts, DNS, paths, proxies, and requests. Learn which signals help diagnose failures without confusing telemetry with service SLOs.

#networking #observability #monitoring

Network Performance: Latency, Throughput, Jitter & Loss

Learn to measure link capacity, throughput, delay variation, packet loss, and response time with ping, iperf3, and curl.

#networking #performance #latency

CPU Affinity & Real-Time Operating Systems

Learn how CPU affinity changes task placement, how Linux real-time policies differ, and why deadline guarantees depend on workload, configuration, and hardware.

#operating-systems #cpu-affinity #scheduling