Polly lets .NET developers compose thread-safe resilience pipelines with retry, circuit breaker, timeout, rate limiting, hedging, and fallback strategies.
Overview
Polly is a .NET library for expressing resilience strategies when calling code that may fail or slow down. Developers combine one or more strategies into a resilience pipeline and execute callbacks through that pipeline.
Reactive strategies handle thrown exceptions or failed results, including retry, circuit breaker, fallback, and hedging. Proactive strategies such as timeout and rate limiter cancel or reject work before overload builds. Starting in Polly 8.3, chaos engineering capabilities from Simmy are integrated into the core.
The Polly.Core package is added via NuGet. Pipelines are built with ResiliencePipelineBuilder. The Polly.Extensions package registers pipelines through dependency injection with AddResiliencePipeline on IServiceCollection.
The project is part of the .NET Foundation. Documentation on pollydocs.org covers each strategy in depth. A maintenance fee model applies to future major versions for qualifying commercial use above a revenue threshold; existing versions and indirect references through certain Microsoft packages are outside that scope.
Key features
- Composable resilience pipelines
- Retry and circuit breaker
- Timeout and rate limiter
- Hedging and fallback
- Dependency injection extensions
- Integrated chaos engineering
- Reactive and proactive strategies
Use cases
- Hardening HTTP client calls
- Protecting services under load
- Handling transient cloud faults
- Injecting controlled failures in tests