4

So, I am looking to increase the Max Pool Size. The problem is that I don't know what a "reasonable" increase would be. Right now I am not setting it, just using the default of 100. The following are my more specific questions:

  1. Why is this number defaulted at 100, seems low. What are the negatives of significantly raising it to 1000 or something like that?

  2. Is there a good way to determine what this Max Should be raised to?

  3. What is the "scope" of the Connection Pool? Is this pool all connections to the database? Each "Machine/Server" connecting has is own Pool?

Background:

While my application is running we received the following error:

"Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached." I have read alot of other post with a similar problem, all of which discuss how I should do one of two things.

  1. Make sure I am closing all connections after opening them
  2. Increase the max pool size

I have an extremely large application, so the (1) is hard to determine if somewhere a connection is not being closed. I can't find one that is not.

4

1 回答 1

10

为什么这个数字默认为 100,似乎很低。

100 个连接大致意味着您每秒可以处理 200 个 500 毫秒的数据库处理,而不会出现连接不足的情况。这是相当高的。如果你达到了这个限制,是时候看看优化了。

将其显着提高到 1000 或类似的东西有什么负面影响?

Is there a good way to determine what this Max Should be raised to?

在粗略的基础上,它应该是每秒需要的连接数乘以释放每个连接之前所需的平均执行时间。例如,如果您需要每秒打开 100 个新连接,每个连接都需要 10 秒才能释放(这将是非常巨大的),那么从长远来看,您需要在池中建立 1000 个连接来处理它。

连接池的“范围”是什么?

我会说它在 AppDomain 上(将检查)

这个池是数据库的所有连接吗?

连接是基于连接字符串池化的。连接字符串中的任何微小差异都会导致不同的池(尽管我不确定它是否区分大小写)

每个“机器/服务器”连接都有自己的池?

关于您的问题,可能有几件事:

  • 您的应用程序接收的流量比它可以处理的多得多(SQL 分析器应该对此有所帮助,然后提高池大小会有所帮助)
  • 您有一些查询需要花费太多时间并且被频繁调用(需要几秒钟,每秒调用几次)造成瓶颈(分析器也会有所帮助)
  • 您在某些嵌套(递归)循环中泄漏连接或打开太多连接
  • 你有这么多的池,你达到了连接的数据库限制(我的 2008R2 Std 上的 32767 Select @@MAX_CONNECTIONS)这似乎不太可能
于 2013-10-11T15:41:55.767 回答