liveBook · Manning

Connection pooling

As explained in .NET in Action, Second Edition

A connection pool is a managed collection of reusable network connections that limits and coordinates simultaneous access.

An asynchronous search can start thousands of HTTP requests without executing them all at once. Tasks are queued for workers from the .NET thread pool, while HttpClient’s connection pool manages how many calls execute simultaneously. These are separate limits: the thread pool supplies workers; the connection pool governs HTTP calls. section 4.4

Searching comics by title

The search creates a task for each of more than 2,600 comics, then uses Task.WhenAll to wait until every comic has been checked. HttpClient’s connection pool helps prevent that fan-out from exhausting network sockets. section 4.4

How .NET in Action, Second Edition covers it

How deep it goes
Identifies HttpClient’s control of simultaneous calls but does not show pool configuration or internals.
Examples
Uses a comic-title search that creates more than 2,600 request tasks and waits with Task.WhenAll.
What you can do after
Evaluate/understand why many queued asynchronous HTTP tasks do not imply equally many simultaneous calls.
How it connects
Connects connection pooling to HttpClient, asynchronous programming, Tasks, and the .NET thread pool.

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 .NET in Action, Second Edition. The section links point to the parts of the book it draws on.