What is the standard resilience handler / Polly, and what does it give you?

ASP.NET Core Performance Advanced 3–5 Yrs5+ Yrs Conceptual 1 min read

Quick Answer

Polly is a resilience library; AddStandardResilienceHandler() (Microsoft.Extensions.Http.Resilience) wires a sensible default pipeline onto an HttpClient: rate limiter → total timeout → retry (with backoff + jitter) → circuit breaker → per-attempt timeout. It turns transient failures of a downstream service into automatic recovery instead of cascading errors.

Polly is the resilience library, and the standard resilience handler is a pre-built pipeline you attach to an HttpClient with one line. It gives you retries with exponential backoff and jitter for transient failures, a circuit breaker that trips after too many failures so you stop hammering a dead service, and timeouts both per attempt and overall. So when a downstream API has a hiccup, the call recovers automatically instead of failing the whole request or cascading. The rule I keep in mind is to only auto-retry idempotent operations.

  • Retry — for transient status codes (408, 429, 5xx) and network errors; exponential backoff with jitter to avoid thundering herds.
  • Circuit breaker — after a failure ratio threshold, “open” and fail fast for a break duration, then “half-open” to test recovery.
  • Timeout — a per-attempt timeout and an overall timeout so one slow call can't hang a request forever.
  • Register per typed client: builder.Services.AddHttpClient<GitHubClient>().AddStandardResilienceHandler();.
  • Only retry idempotent operations; use idempotency keys for POSTs.