Optimizing your HttpClient usage
summary
Shows that creating 20,000 new HttpClient instances exhausts sockets after a 2s API delay and explains why reusing connections matters: DNS, TCP handshake and TLS handshake happen on new connections. Demonstrates using IHttpClientFactory with named and typed clients, warns about shared cookie containers and the default 2‑minute handler timeout, covers delegating handlers and OpenTelemetry instrumentation, and uses Polly for exponential backoff with jitter and a circuit breaker (3 failures → open 5s) to reduce thundering‑herd retries.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:58HTTP client usage in .NET
- 3:45HTTP client pitfalls
- 5:53Disposing HTTP clients
- 8:40TCP/TLS handshakes
- 10:50Live demo: HTTP misuse
- 13:20Fixing HTTP usage with DI
- 17:47HTTP client factory
- 21:25Blazor HTTP calls
- 27:12Handling responses/exceptions
- 30:16Named HTTP clients
- 33:04Typed HTTP clients
- 36:17Delegating handlers
- 44:35OpenTelemetry integration
- 48:10Resiliency patterns
- 51:15Polly policies
- 59:16Resources & closing
related talks
56mOptimizing your HttpClient usage
01h 31mFive Design Patterns to build resilient Applications
56mSystem Stable : Robust connected applications with Polly
42mBulletproof Transient Error Handling with Polly
52mRoad to .NET 6: migration story of hope and despair
01h 01mPractical OpenTelemetry in .NET 8
43mPeter Paul Bakker: The Power of Automated Resilience Tests
46mProxy Pains and Benefits Supporting HTTP/2 End to End
