diff --git a/docs/core/resilience/http-resilience.md b/docs/core/resilience/http-resilience.md index 4a206c23785ab..ed55448489e25 100644 --- a/docs/core/resilience/http-resilience.md +++ b/docs/core/resilience/http-resilience.md @@ -3,7 +3,7 @@ title: "Build resilient HTTP apps: Key development patterns" description: Learn how to build resilient HTTP apps using the Microsoft.Extensions.Http.Resilience NuGet package. author: IEvangelist ms.author: dapine -ms.date: 10/20/2023 +ms.date: 07/01/2024 --- # Build resilient HTTP apps: Key development patterns @@ -81,13 +81,26 @@ The preceding code adds the standard resilience handler to the Permit: `1_000` | +| **2** | Total timeout | The total request timeout pipeline applies an overall timeout to the execution, ensuring that the request, including retry attempts, doesn't exceed the configured limit. | Total timeout: 30s | +| **3** | Retry | The retry pipeline retries the request in case the dependency is slow or returns a transient error. | Max retries: `3`
Backoff: `Exponential`
Use jitter: `true`
Delay:2s | +| **4** | Circuit breaker | The circuit breaker blocks the execution if too many direct failures or timeouts are detected. | Failure ratio: 10%
Min throughput: `100`
Sampling duration: 30s
Break duration: 5s | +| **5** | Attempt timeout | The attempt timeout pipeline limits each request attempt duration and throws if it's exceeded. | Attempt timeout: 10s | + +#### Retries and circuit breakers + +The retry and circuit breaker strategies both handle a set of specific HTTP status codes and exceptions. Consider the following HTTP status codes: + +- HTTP 500 and above (Server errors) +- HTTP 408 (Request timeout) +- HTTP 429 (Too many requests) + +Additionally, these strategies handle the following exceptions: + +- `HttpRequestException` +- `TimeoutRejectedException` ## Add standard hedging handler @@ -108,13 +121,13 @@ The standard hedging uses a pool of circuit breakers to ensure that unhealthy en The preceding code adds the standard hedging handler to the . The default configuration chains five resilience strategies in the following order (from the outermost to the innermost): -| Order | Strategy | Description | -|--:|--|--| -| **1** | Total request timeout | The total request timeout pipeline applies an overall timeout to the execution, ensuring that the request, including hedging attempts, doesn't exceed the configured limit. | -| **2** | Hedging | The hedging strategy executes the requests against multiple endpoints in case the dependency is slow or returns a transient error. Routing is options, by default it just hedges the URL provided by the original . | -| **3** | Rate limiter (per endpoint) | The rate limiter pipeline limits the maximum number of concurrent requests being sent to the dependency. | -| **4** | Circuit breaker (per endpoint) | The circuit breaker blocks the execution if too many direct failures or timeouts are detected. | -| **5** | Attempt timeout (per endpoint) | The attempt timeout pipeline limits each request attempt duration and throws if it's exceeded. | +| Order | Strategy | Description | Defaults | +|--:|--|--|--| +| **1** | Total request timeout | The total request timeout pipeline applies an overall timeout to the execution, ensuring that the request, including hedging attempts, doesn't exceed the configured limit. | Total timeout: 30s | +| **2** | Hedging | The hedging strategy executes the requests against multiple endpoints in case the dependency is slow or returns a transient error. Routing is options, by default it just hedges the URL provided by the original . | Min attempts: `1`
Max attempts: `10`
Delay: 2s | +| **3** | Rate limiter (per endpoint) | The rate limiter pipeline limits the maximum number of concurrent requests being sent to the dependency. | Queue: `0`
Permit: `1_000` | +| **4** | Circuit breaker (per endpoint) | The circuit breaker blocks the execution if too many direct failures or timeouts are detected. | Failure ratio: 10%
Min throughput: `100`
Sampling duration: 30s
Break duration: 5s | +| **5** | Attempt timeout (per endpoint) | The attempt timeout pipeline limits each request attempt duration and throws if it's exceeded. | Timeout: 10s | ### Customize hedging handler route selection