2026-06-09 / C# / .NET Core
HttpClientFactory and Polly: Making External HTTP Calls More Resilient
Stable external HTTP calls come from combining client lifetime, timeout, retry, circuit breaking, and fallback.
.NETASP.NET Core
HttpClientFactory and Polly: Making External HTTP Calls More Resilient
External HTTP calls are naturally unstable: network jitter, DNS changes, rate limits, and occasional 5xx responses happen. Reliability cannot be solved by blindly retrying.
Call Flow
sequenceDiagram
participant H as Handler
participant C as Typed HttpClient
participant P as Polly Policy
participant API as External API
H->>C: Call third-party service
C->>P: Apply timeout / retry / circuit breaker
P->>API: HTTP request
API-->>P: 2xx / 5xx / timeout
P-->>C: Success / fallback / fast fail
C-->>H: Business result
Engineering Scenario
HttpClientFactory manages handler lifetime and connection reuse. Polly manages failure policies. Together they make timeout, retry, and circuit-breaking behavior explicit.
Best Practices
- Set clear timeouts first.
- Retry only transient failures.
- Keep retry counts small and observable.
- Design circuit breaking, fallback, and alerts together.