If you are handling large databases and big application(s) that are running on servers in a cluster, then probably this error might have occurred. In an ASP.NET app, we can use connection pooling that helps to share the connection between multiple request(s) rather than creating more connections. The settings relating to connection pool are defined in web.config file.
And the following shows the how to exactly specify the settings in the connection string within web.config:
"integrated security=SSPI;SERVER=YOUR_SERVER;DATABASE=YOUR_DB_NAME;Min Pool Size=5;Max Pool Size=60;Connect Timeout=60;"
Max pool size reached error in ASP.NET occurs, when the number of connections go beyond the maximum defined limit in Web.config file. Following are the various settings of the Connection Pooling:
Name
|
Default
|
Description
|
Connection Lifetime
|
0
|
When a connection is returned to the pool, its creation time is
compared with the current time, and the connection is destroyed if that time
span (in seconds) exceeds the value specified by Connection Lifetime.
This is useful in clustered configurations to force load balancing between a
running server and a server just brought online.
A value of zero (0)
will cause pooled connections to have the maximum time-out.
|
Connection Reset
|
'true'
|
Determines whether the database connection is reset when being
removed from the pool. For Microsoft SQL Server version 7.0, setting to false avoids
making an additional server round trip when obtaining a connection, but you
must be aware that the connection state, such as database context, is not
being reset.
|
Enlist
|
'true'
|
When true, the pooler automatically enlists the
connection in the current transaction context of the creation thread if a
transaction context exists.
|
Max Pool Size
|
100
|
The maximum number of connections allowed in the pool.
|
Min Pool Size
|
0
|
The minimum number of connections maintained in the pool.
|
Pooling
|
'true'
|
When true, the connection is drawn from the
appropriate pool, or if necessary, created and added to the appropriate pool.
|
And the following shows the how to exactly specify the settings in the connection string within web.config:
"integrated security=SSPI;SERVER=YOUR_SERVER;DATABASE=YOUR_DB_NAME;Min Pool Size=5;Max Pool Size=60;Connect Timeout=60;"
Comments