I used to understand the Min Pool Size in the connection string incorrectly.

Source: Internet
Author: User

Suppose we set the Min Pool Size to 30 in the connection string of an ASP. NET application:

<add name="cnblogs" connectionString="Data Source=.;Initial Catalog=cnblogs;Min Pool Size=30" providerName="System.Data.SqlClient"/>

Access the application and use Windows Performance Monitor to Monitor. NET Data Provider for SqlServer-> NumberOfPooledConnections (total number of connections in the connection pool ):

 

The total number of connections in the connection pool is not 30, but 60 (SEE ). Min Pool Size = 30. Why is NumberOfPooledConnections 60?

Use Performance Monitor to Monitor. NET Data Provider for SqlServer-> NumberOfActiveConnectionPools:

 

There were two Connection pools, 60 (NumberOfPooledConnections) = 30 (Min Pool Size) × 2 (NumberOfActiveConnectionPools), and 60 was the same.

What if the number of database connections required by the application exceeds 60?

NumberOfPooledConnections changes to 90, that is, ADO. NET creates a new connection Pool (NumberOfActiveConnectionPools changes from 2 to 3), and the connection Pool contains 30 connections (Min Pool Size = 30 ).

When I found this, I realized that my previous understanding of the Min Pool Size was totally wrong. I thought there was only one connection Pool. When Min Pool Size = 30 is set, 30 database connections will be created during the initial creation of the connection Pool. When 30 connections are insufficient, it can be created as much as needed.

The explanation of Min Pool Size in MSDN is really simple: the minimum number of connections maintained in The pool.

It proves the truth again.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.