how long must a sql server connection be idle before it is closed by the connection pool?

夙愿已清 提交于 2019-11-30 08:45:27

A few years ago the answer beneath was the situation, but now it's changed so you can refer to the source and write up a summary :)


Old answer

This excellent article tells us what we need to know, using reflection to reveal the inner workings of connection pooling.

From how I understand it, 'closed' connections are cleaned up periodically on a semi-random interval. The cleanup process runs somewhere between every 2min and 3min 50s, but it needs to run twice before a 'closed' connection will be properly closed. Therefore after 7min 40s of being 'closed' the underlying sql connection should be properly closed, but it could be as short as 2min. At the time of writing the first connection pool created in a process would always have a timer interval of 3min 10s, so you'd normally see sql connections being closed somewhere between 3min 10s and 6min 20s after you call Close() on the ADO object.

Obviously this uses undocumented code so could change in future - or could even have changed since that article was written.

Please go through this:

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring%28VS.80%29.aspx

The part

"The following table lists the valid names for connection pooling values within the ConnectionString."

seems to be of your interest.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!