Connection Pooling

connection_poolingConnection pooling is the ability of reusing your connection to the database. This means if you enable Connection pooling in the connection object, actually you enable the re-use of the connection to more than one user.
ADO.NET uses a technique called connection pooling, which minimizes the cost of repeatedly opening and closing connections. Connection pooling reuses existing active connections with the same connection string instead of creating new connections when a request is made to the database. It involves the use of a connection manager that is responsible for maintaining a list, or pool, of available connections for a given connection string. Several pools exist if different connection strings ask for connection pooling.
A Connection String in the Web.Config file with connection pooling option:

    <add name="sqlConnectionString" connectionString="Data Source=mySQLServer;Initial Catalog=myDatabase;Integrated Security=True;Connection Timeout=15;Connection Lifetime=0;Min Pool Size=0;Max Pool Size=100;Pooling=true;"/>

SQL Server connection string pooling attributes

  • Connection Lifetime:
    • Length of time in seconds after creation after which a connection is destroyed. The default is 0, indicating that connection will have the maximum timeout.
  • Connection Reset:
    • Specifies whether the connection is reset when removed from the pool. The default is true.
  • Enlist:
    • Specifies whether the connection is automatically enlisted in the current transaction context of the creation thread if that transaction context exists. The default is true.
  • Load Balance Timeout:
    • Length of time in seconds that a connection can remain idle in a connection pool before being removed.
  • Max Pool Size:
    • Maximum number of connections allowed in the pool. The default is 100.
  • Min Pool Size:
    • Minimum number of connections maintained in the pool. The default is 0.
  • Pooling:
    • When true, the connection is drawn from the appropriate pool, or if necessary, created and added to the appropriate pool. The default is true.

Leave a Reply

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