In C# it is possible to enable/disable Connection Pooling by using "Pooling=True" and "Max Pool Size=XY" in connection string.
Like: What is maximum allowable value of "Max Pool Size" in sql connection string
Is it possible to ask how many connections to SQL server is active and what is the current pool size programmatically?
A connection pool is created for each unique connection string. When a pool is created, multiple connection objects are created and added to the pool so that the minimum pool size requirement is satisfied. Connections are added to the pool as needed, up to the maximum pool size specified (100 is the default).
For optimal performance, use a pool with eight to 16 connections per node. For example, if you have four nodes configured, then the steady-pool size must be set to 32 and the maximum pool size must be 64. Adjust the Idle Timeout and Pool Resize Quantity values based on monitoring statistics.
The sqlConnection will close the connection after it will pass using block and call Dispose method. SqlConnection. Dispose() equal to SqlConnection.
You can use NumberOfActiveConnections or NumberOfPooledConnections ADO.NET performance counter:
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/performance-counters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With