Polly is part of the .NET Foundation and supports .NET Standard 1.1, 2.0+, .NET Core, .NET Framework, and .NET 6+.
What is Polly?
Modern applications often depend on external services, databases, and APIs that can fail temporarily or become unavailable. Polly helps you handle these transient faults gracefully by providing a comprehensive set of resilience strategies that you can combine and configure to match your specific requirements. With Polly, you can:- Retry operations that fail due to transient faults
- Break circuits when a system is under stress to prevent cascading failures
- Add timeouts to prevent operations from hanging indefinitely
- Rate limit requests to protect your services from overload
- Provide fallback values when operations fail
- Hedge requests by executing parallel operations and taking the fastest response
- Inject chaos to test your application’s resilience
Key Features
Retry Strategy
Automatically retry failed operations with exponential backoff and jitter
Circuit Breaker
Prevent cascading failures by breaking the circuit when fault thresholds are exceeded
Timeout Management
Set time limits on operations to prevent them from running indefinitely
Rate Limiting
Control the rate of requests with multiple rate limiting algorithms
Fallback Handlers
Provide alternative values or actions when operations fail
Hedging
Execute parallel actions and use the fastest successful response
Chaos Engineering
Test your application’s resilience by injecting controlled faults
Telemetry Support
Built-in telemetry and monitoring for all resilience strategies
How Polly Works
Polly uses a resilience pipeline pattern that combines one or more resilience strategies into a unified execution flow. You build pipelines using a fluent builder API:NuGet Packages
Polly is distributed as a set of NuGet packages:| Package | Purpose |
|---|---|
| Polly.Core | Core abstractions and built-in resilience strategies |
| Polly.Extensions | Dependency injection and telemetry integration |
| Polly.RateLimiting | Integration with System.Threading.RateLimiting APIs |
| Polly.Testing | Testing utilities for Polly pipelines |
| Polly | Legacy v7 API for backward compatibility |
This documentation covers Polly v8, which introduces a new, more powerful API. If you’re using Polly v7, see the migration guide.
Why Choose Polly?
Battle-tested and widely adopted
Battle-tested and widely adopted
Polly is used by thousands of applications worldwide, including Microsoft’s own services. It has been refined over years of production use.
Flexible and composable
Flexible and composable
Combine multiple resilience strategies in any order to create sophisticated fault-handling behaviors tailored to your needs.
Performance-focused
Performance-focused
Designed for high-performance scenarios with minimal allocation and overhead. Supports async/await throughout.
Comprehensive telemetry
Comprehensive telemetry
Built-in support for logging, metrics, and distributed tracing to help you understand your application’s resilience.
Dependency injection ready
Dependency injection ready
First-class support for Microsoft.Extensions.DependencyInjection with lifecycle management and configuration.
Extensible
Extensible
Create custom resilience strategies to address unique requirements in your application.
Next Steps
Installation
Install Polly and set up your first project
Quickstart
Build your first resilience pipeline in minutes
Core Concepts
Learn about resilience pipelines and strategies
API Reference
Explore the complete API documentation