October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Monitor Database Connection Pool Usage in ASP.NET Core

Monitor ASP.NET Core connection pools through SqlClient EventCounters or Npgsql metrics. Learn which signals show active use, idle capacity, reuse, and pool proliferation.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Monitor the connection pool in the database driver, not in EF Core. For SQL Server with Microsoft.Data.SqlClient, attach dotnet-counters to the ASP.NET Core process and inspect SqlClient EventCounters. For PostgreSQL with Npgsql, inspect the provider’s .NET metrics, including connections by state and pool identity. EF Core metrics add useful context about queries and failures, but they do not report driver-pool occupancy.

Start with the provider and its version

Pool metrics and their names depend on the driver. First identify the provider package and version deployed by the application, then check its documented runtime requirements and metric names. The commands below attach to an already running ASP.NET Core process; replace the process-ID placeholder with that process’s ID.

As an Amazon Associate I earn from qualifying purchases.

  1. Identify the provider. Use SqlClient metrics for SQL Server applications using Microsoft.Data.SqlClient, or Npgsql metrics for PostgreSQL applications using Npgsql.
  2. Find the process ID. Identify the running ASP.NET Core process that you want to observe.
  3. Run the provider-specific monitor. Keep the measurement window and workload in mind when comparing readings.
  4. Correlate the readings. Compare pool signals with request rates, database latency, exceptions, and EF Core activity.
  5. Check pool configuration. Interpret counts against the deployed provider’s configured limits, rather than assuming a universal pool-size threshold.

Monitor Microsoft.Data.SqlClient pools

For Microsoft.Data.SqlClient, use its EventSource with dotnet-counters:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
dotnet-counters monitor --counters Microsoft.Data.SqlClient.EventSource -p <process-id> --refresh-interval 3

SqlClient also documents selecting particular counters, such as hard-connects and hard-disconnects. EventCounters require Microsoft.Data.SqlClient 3.0.0 or later and .NET Core 3.1 or .NET Standard 2.1 or later; use the provider’s framework-specific guidance for other configurations. SqlClient distinguishes these modern cross-platform EventCounters from .NET Framework performance counters. See the Microsoft.Data.SqlClient EventCounters documentation.

Read the counters together

  • number-of-active-connections counts connections currently in use; number-of-free-connections counts connections ready in pools.
  • number-of-pooled-connections reports connections managed by the pooling infrastructure. It is not the same as the number currently in use.
  • number-of-active-connection-pools and number-of-active-connection-pool-groups can reveal pool proliferation. Pool groups correspond to unique connection strings; Windows integrated authentication can create separate pools per Windows identity within a group.
  • hard-connects and hard-disconnects track physical connections opened to and disconnected from database servers. soft-connects and soft-disconnects track connections retrieved from and returned to a pool.
  • number-of-stasis-connections counts connections waiting for an action to complete and unavailable to the application.
  • number-of-reclaimed-connections counts connections reclaimed through garbage collection because the application did not call Close or Dispose. Repeated growth is a reason to inspect disposal paths.

High active use with few free connections, especially near configured capacity, can indicate pressure. Rising pool counts can point to many distinct connection strings or identities. Frequent hard connections relative to pooled reuse can indicate that physical connections are being established often. These patterns are diagnostic clues, not proof of a single cause.

Monitor Npgsql pools

For Npgsql, monitor its .NET meter with dotnet-counters:

dotnet-counters monitor --counters Npgsql -p <PID>

Review connection counts split by idle and used, the maximum connection count, and the pool or data-source identity. Use the identity dimension to distinguish multiple databases or data sources. By default, the pool name is the connection string; an Npgsql data source can instead be given a more stable explicit name. Npgsql pools connections by default, and disposing an Npgsql connection returns it to the internal pool. See the Npgsql metrics documentation and connection-string parameters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Npgsql documents a maximum pool size of 100 since version 3.1, but that is a provider-specific default, not a recommended limit for every application. Verify the deployed version and configuration. Npgsql 10.0 renamed metrics to align with OpenTelemetry, so update dashboard queries and alerts to match the version in use. See the Npgsql 10.0 release notes.

Use EF Core metrics as supporting signals

EF Core metrics describe EF-level activity, not the driver’s pool inventory. EF Core 9.0 introduced System.Diagnostics.Metrics reporting; its Microsoft.EntityFrameworkCore meter and legacy counters can help track activity and failures. Metrics such as active_dbcontexts, query activity, saves, and failures do not tell you how many driver connections are idle, used, or available. See the EF Core metrics documentation.

Connection pooling is implemented by the database driver and is separate from EF Core DbContext pooling. EF Core generally opens a connection close to an operation and closes it afterward so the driver can return it to its pool. Turning on context pooling therefore does not expose or measure connection-pool occupancy. See EF Core’s connection-pooling guidance.

Choose the signal that answers the question

Monitoring approach Direct pool-state visibility Pool or data-source dimension Physical connection versus reuse signal Version and fit considerations
Microsoft.Data.SqlClient EventCounters Active, free, pooled, and stasis connection counts Active pools and pool groups; grouping is affected by connection strings and, for integrated authentication, Windows identities Hard and soft connects and disconnects EventCounters require Microsoft.Data.SqlClient 3.0.0 or later and .NET Core 3.1 or .NET Standard 2.1 or later; check provider guidance for other configurations.
Npgsql .NET metrics Used and idle connection counts plus maximum connection count Pool or data-source identity These cited metrics describe pool state; they do not provide the SqlClient hard/soft counter names Metric names changed in Npgsql 10.0; align dashboards and alerts with the deployed version.
EF Core metrics No direct driver-pool inventory EF Core application activity, rather than driver pool identity Query, save, and failure activity can be correlated with provider signals EF Core 9.0 introduced System.Diagnostics.Metrics reporting; these metrics do not replace provider instrumentation.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Interpret trends without guessing at a universal limit

Compare active or used connections with free or idle connections and the configured maximum for the specific provider and data source. Track those values over time under a known workload, alongside request volume, database latency, and errors. A high active count alone does not establish a pool problem: slow queries, server-side connection failures, or a workload increase can produce different symptoms that need to be separated with correlated signals. Likewise, a spike in pool count or hard connections is a lead to investigate, not a diagnosis.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • If active or used connections approach the configured maximum while free or idle capacity stays low, investigate connection hold times and workload behavior.
  • If SqlClient hard-connect activity is high compared with soft reuse, inspect whether the application is repeatedly establishing physical connections.
  • If pool counts grow, examine connection-string variation and, for SqlClient with integrated authentication, identity-related pool separation.
  • If reclaimed SqlClient connections repeatedly rise, review whether every opened connection is closed or disposed on all code paths.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.