liveBook · Manning

Connection pooling

As explained in ASP.NET Core in Action, 3e

Connection pooling is the reuse of established network connections across multiple client requests to reduce connection-setup overhead.

Connection pooling reuses established network connections for multiple client requests, reducing connection-setup overhead. In .NET, SocketsHttpHandler supports pooling and recycling, while IHttpClientFactory manages handler lifetime and reuse. section 33.2.1

Pool connections with IHttpClientFactory

Register the factory with builder.Services.AddHttpClient(), inject IHttpClientFactory into an endpoint, create an HttpClient, set its BaseAddress, and call the remote API. The factory creates a client whose handler it manages. section 33.2.1

Figure 33.4 Each HttpClient contains a pipeline of HttpMessageHandlers. The final handler is an HttpClientHandler, which makes the connection to the remote server and sends the HTTP request. This configuration is similar to the ASP.NET Core middleware pipeline, and it allows you to make cross-cutting adjustments to outgoing requests.
CH33_F04_Lock3

Trace how HttpClient handlers form a pipeline and how the final handler connects to the remote server. section 33.2.1

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains handler lifetime, pooling, and recycling, but defers detailed manual SocketsHttpHandler configuration.
Examples
Uses an ASP.NET Core endpoint calling https://example.com/rates/latest through a factory-created HttpClient.
What it assumes
Assumes familiarity with HttpClient and remote API calls while showing factory registration and injection explicitly.
What you can do after
Operate pooled HTTP clients through IHttpClientFactory in dependency-injected .NET applications.
How it connects
Connects connection pooling with HttpClient, SocketsHttpHandler, IHttpClientFactory, dependency injection, and HTTP handlers.

Also explained in

Compare how 9 books explain connection pooling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.