Sql Server Max Pool Size 最大连接数的问题

使用 hangfire 执行一个 big 大的后台任务,默认是最大同时执行20个。 测试的时候,发现太少了,导致总执行时间太长,,, 一怒之下,直接改成了 100 。  然后问题来了,开发机 CPU 100%,内存 100% , 然后就是 

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.

中文的意思就是:超时时间已到,但是尚未从池中获取连接。出现这种情况可能是因为所有池连接均在使用,并且达到了最大池大小。 

看下连接字符串,没有设置Max Pool Size ,也就是说是默认的100 ,hangfire 同时执行 100 个任务,相当于 100 个人同时访问,超出的 在超出等待时间之后,就会抛出上面的这个错误。

PS:查询数据库当前连接数:

select * from sysprocesses where dbid in (select dbid from sysdatabases where name='you database name')

已禁用评论。