Interview frequency: …
Short answer
Use Microsoft.Extensions.Resilience to combine Retry, Circuit Breaker, Timeout, and Rate Limiter strategies in a unified, flexible pipeline for network calls.
Explanation
Polly v8 was redesigned to be very fast with little extra allocation and officially integrated with .NET HTTP clients through AddResilienceHandler(). You can configure a pipeline with retries using Exponential Backoff and Jitter for unstable networks, a Circuit Breaker that protects your server when a dependency fails, and a maximum timeout for each attempt.
Code example
builder.Services.AddHttpClient("ExternalService")
.AddStandardResilienceHandler(options => {
options.Retry.MaxRetryAttempts = 3;
options.CircuitBreaker.SamplingDuration = TimeSpan.FromSeconds(30);
});Common mistakes
- Retrying immediately without Jitter (random delay), causing simultaneous requests that take down a remote server (Thundering Herd Problem).