Video in progress

How do you choose the SLI and SLO for a payment API? Why is "99.9% uptime" not a good SLO?

An SLI should measure what the user feels: the share of successful requests and the share of responses faster than a given threshold. "Uptime" measures whether the server is alive, but a pod can be running and return 500 on 30% of requests.

📖 Answer

"99.9% uptime" is usually taken from a ping or a health check. The health check is green, but the connection to the payment provider is down: for the user the service is not working, yet the SLO is met. So I write the SLI on requests, as "good events / all events".

An example for a payment API:

SLI Definition SLO (28 days)
Availability non-5xx responses / all responses (4xx is a client error and is not counted) 99.9%
Latency responses faster than 800 ms / all responses 99%
Correctness payments that were not charged twice / all payments (from the reconciliation job) 99.999%
# availability SLI, Prometheus
sum(rate(http_server_requests_seconds_count{uri="/payments",status!~"5.."}[5m]))
/ sum(rate(http_server_requests_seconds_count{uri="/payments"}[5m]))

What to consider when choosing:

  • Where to measure: a metric inside the application doesn't see requests that never reached it from the load balancer. When I can, I take the SLI from the ingress or LB metrics.
  • How to pick the number: first I measure for a month and look at where we are now. Promising 99.99% and then breaking it every week leads to nobody taking the SLO seriously.
  • Dependencies: if the provider itself offers 99.9%, you can't promise higher availability than that (unless you have retries and a fallback).

The SLO is an internal target. The SLA in a contract with a customer should be looser than it, otherwise every small breach turns into a penalty.