Table of Contents

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!

Polly logo

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.
  • vanced topics: A collection of advanced topics for further learning.
  • Community and resources: A collection of resources and community contributions.
  • API: The API documentation for the project.

Articles (previous Polly versions)

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.