ASP.NET Core & Web API (50 Qs)•Part 3: Distributed Systems, Kestrel Internals & Scalability (25 - 35)
Resilient HTTP Clients with Polly Resilience Pipelines.
senior LevelCode ExampleCLIPipesCI/CD & DevOps
In Simple Words:
Calling external microservices using raw HttpClient risks socket exhaustion and cascading outages.
IHttpClientFactory: Manages underlyingHttpMessageHandlerlifetimes to prevent DNS caching bugs and socket exhaustion.- Polly Resilience Pipelines (.NET 8+): Composes retries with exponential backoff, circuit breakers, and rate limiters into a single fluent pipeline.
csharp
builder.Services.AddHttpClient("PaymentService")
.AddStandardResilienceHandler(options => {
options.Retry.MaxRetryAttempts = 3;
options.CircuitBreaker.SamplingDuration = TimeSpan.FromSeconds(30);
});