Polly Documentation
Polly is a .NET resilience and transient-fault-handling library that allows developers to express resilience strategies such as Retry, Circuit Breaker, Hedging, Timeout, Rate Limiter and Fallback in a fluent and thread-safe manner.
We are a member of the .NET Foundation!
Resilience strategies
Strategy | Reactive | Premise | AKA | How does the strategy mitigate? |
---|---|---|---|---|
Retry | Yes | Many faults are transient and may self-correct after a short delay. | Maybe it's just a blip | Allows configuring automatic retries. |
Circuit-breaker | Yes | When a system is seriously struggling, failing fast is better than making users/callers wait. Protecting a faulting system from overload can help it recover. |
Stop doing it if it hurts Give that system a break |
Breaks the circuit (blocks executions) for a period, when faults exceed some pre-configured threshold. |
Timeout | No | Beyond a certain wait, a success result is unlikely. | Don't wait forever | Guarantees the caller won't have to wait beyond the timeout. |
Rate Limiter | No | Limiting the rate a system handles requests is another way to control load. This can apply to the way your system accepts incoming calls, and/or to the way you call downstream services. |
Slow down a bit, will you? | Constrains executions to not exceed a certain rate. |
Fallback | Yes | Things will still fail - plan what you will do when that happens. | Degrade gracefully | Defines an alternative value to be returned (or action to be executed) on failure. |
Hedging | Yes | Things can be slow sometimes, plan what you will do when that happens. | Hedge your bets | Executes parallel actions when things are slow and waits for the fastest one. |
Visit the resilience strategies section to understand their structure and explore various configuration methods.
Next steps
Visit the getting started section and learn how to quickly start using Polly.
Articles
- Introduction: General information about the project and its goals.
- Getting started: A guide to help you get started with the project.
- Resilience strategies: A collection of strategies for improving the resilience of your system.
- Timeout: A strategy for setting a maximum time limit for a request.
- Retry: A strategy for retrying failed requests.
- Rate limiter: A strategy for limiting the rate of requests.
- Hedging: A strategy for hedging against long request times.
- Fallback: A strategy for providing a fallback response in case of failure.
- Circuit breaker: A strategy for breaking the circuit when a system is down.
- Resilience pipelines: Understanding the use of resilience pipelines.
- Resilience pipeline registry: Exploring the registry that stores resilience pipelines.
- vanced topics: A collection of advanced topics for further learning.
- Telemetry and monitoring: Insights into telemetry generated by resilience pipelines and strategies.
- Chaos engineering: Get to know chaos engineering via the project's capabilities.
- Dependency injection: How the project integrates with Dependency Injection.
- Community and resources: A collection of resources and community contributions.
- Polly-Contrib projects and libraries: Learn how to contribute to and extend the project ecosystem.
- Libraries and contributions: Find out which libraries the project depends on and who contributes to its development.
- Useful resources and links: Browse through blogs, podcasts, courses, e-books, and other community resources.
- API: The API documentation for the project.
Articles (previous Polly versions)
- Extensibility (v7): Learn how you can extend Polly with new policies.
Samples
- Samples: Samples in this repository that serve as an introduction to Polly.
- Polly-Samples: Contains practical examples for using various implementations of Polly. Please feel free to contribute to the Polly-Samples repository in order to assist others who are either learning Polly for the first time, or are seeking advanced examples and novel approaches provided by our generous community.
- Microsoft's eShopOnContainers project: Sample project demonstrating a .NET Microservices architecture and using Polly for resilience.