ARTICLE

How connection pooling works in ADO.NET

Posted by Sapna Articles | ADO.NET in VB.NET July 14, 2010
This article is about how connection pooling makes the process of connecting to ADO.NET data sourcse more efficient.
 
Reader Level:

The basic idea behind connection polling is that a pool of database connections is available to one or more users of a database. When a user attempts to connect to the database, ADO.NET checks to see if an existing connection can be retrieved from a connection pool. If  a program requests  a connection and one isn't available in the pool, a new connection is created unless the maximum number of the connection for the pool are already in use. In that case, the program must wait for a connection to become available. 

pooling.gif 
                                                    
Each connection pool contains a limited number of connections. Because of that, if a large number of user attempt to access the database using the same connection string, it's likely that some users will have to wait for a connection.


Importance of connection pooling

In developing an application that will run in a Web-based or multi-tier environment, pooling becomes very important. Making connections to the database can be one of the application's most time-consuming activities. Maintaining connections to the database in the resource state of the Web server can create scalability problems because all users are forced through the same connection object (not to mention that Web servers are almost by definition "stateless"). Opening a new connection on every page of a Web server is bad because it's slow. MDAC pooling provides a way to get the best of both scenarios: a limited number of connections (just enough to match your system's current load) without introducing a scalability bottleneck.

pooling2.gif

Connection pooling programs let you reduce database-related overhead when it's the sheer number of physical connections dragging performance down. This is particularly important on Windows, where system limitations prevent large number of connections.

How does the pool maintenance thread work?


The behaviour of the pool maintenance thread is determined by the value of four properties of the connection pool:
  • Aged timeout: The amount of time a connection will be open.

  • Minimum connections: The minimum number of connections the Connection Manager will keep in a connection factory's free pool.

  • Reap time: How often the pool maintenance thread will run.

  • Unused timeout: How long a connection will remain in the free pool before it is closed.

  

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Become a Sponsor