Developers still do this:
var client = new HttpClient(); // ❌ NEVER do this
Creating HttpClient per request causes:
-
Port exhaustion
-
DNS reuse issues
-
Slowdown under load
-
Socket exceptions
✔ The ONLY Correct Pattern
builder.Services.AddHttpClient();
Or for minimal APIs:
var client = httpClientFactory.CreateClient();
💡 The Life-Saving Insight
If you see:
-
random timeouts
-
slow downstream calls
-
unexplained 60-second delays
…it’s almost always HttpClient mismanagement.
