为什么把我们的.NET / SQL Server的网站到一个新的主机导致连接池的大小被超过? [英] Why would moving our .NET /SQL Server website to a new host cause connection pool size to be exceeded?

查看:190
本文介绍了为什么把我们的.NET / SQL Server的网站到一个新的主机导致连接池的大小被超过?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我们搬到我们公司的网站到一个新的主机。 它是用C#code的ASP.NET网站的背后,连接到MS SQL服务器。

We've recently moved our company website to a new host. It is an ASP.NET site with C# code behind, connecting to MS SQL server.

由于移动网站到新的服务器,该网站是超过了连接池的限制(未明确设置,所以我认为这是在100的默认大小)。 通过SQL Server管理Studiorevealed开放进程的检验,每一个数据库调用出现悬空,而事实上,在code我找不到任何明确在全封闭的连接。

Since moving the site to the new server, the site is exceeding the connection pool limit (which is not set explicitly, so I believe is at the default size of 100). Inspection of the open processes via SQL Server Management Studiorevealed that every database call appeared to be left open, and indeed, in the code I can find no explicitly closed connections at all.

的数据库连接以下列方式制成:

The database connections are made in the following way:

DSLibrary.DataProviders.SqlProvider db = new DSLibrary.DataProviders.SqlProvider(Defaults.ConnStr);

有关于这DSLibrary precious小的文件,我认为这是写的网站的原始开发商库。没有一个DSLibrary的类成员似乎明确地关闭了连接或者 - 也不是中定义的使用块自动关闭连接

我的问题是2倍。

  1. 如何,我们还没有遇到过 这个问题时,该网站是一个 不同的主机将近3年? 有没有去自动关闭 我有没有未使用的连接 实施SQL服务器上?
  2. 我会是最好关闭改写每 连接及程序 明确地打开和关闭 连接数据库?
  1. How would we have not encountered this problem when the site was on a different host for nearly 3 years? Is there away to automatically close unused connections that I have not implemented on the SQL server?
  2. Will I be best off rewriting every connection and procedure to explicitly open and close the connection database?

更新 并发连接属性的最大数量。(服务器属性 - >连接选项卡)设置为0

UPDATE The maximum number of concurrent connections property (Server Properties -> Connections tab) is set to 0.

如果我运行在调试模式下在网站上我的开发机,远程生产数据库的连接,然后将连接似乎正常关闭。这似乎表明它是与IIS的配置方式?

If I run the website in debug mode on my development machine, connecting remotely to the production database, then the connections seem to close properly. This seems to show it's something to do with the way IIS is configured?

更新2 设置应用程序池后30个工作进程回收已停止该网站超过最大连接数,但现在已经限制了一些(会话持续性)功能 - 一个最近访问过的物品清单重置速度非常快,并试图通过CMS编辑什么是不可能的,因为你是注销尽快的处理回收...

UPDATE 2 Setting the application pool to recycle after 30 worker processes has stopped the site exceeding maximum connections, but is now limiting some (session persistent) functionality - a recently visited items list resets very quickly and attempting to edit anything via the cms is impossible as you are logged out as soon as the processes recycle...

推荐答案

最有可能你的code泄漏连接所有的地方。

Most likely your code is leaking connections all over the place.

我敢打赌你的旧主机有应用程序池设置为常循环pretty的,无论是从内存使用或#请求处理点。新主机最可能具有默认的骑自行车的地方。

I'd bet money your old host had the app pool set to recycle pretty often, either from a memory usage or # requests processed point. The new host most likely has default cycling in place.

我的建议是首先设置应用程序池更频繁地回收了不少。然后修复code。无论是通过重构出DSLibrary(猜测这是家庭长大的),或者通过简单地改变其移交给使用条款。无论您有数据库连接进行。

My recommendation is to first set the app pool to recycle a lot more often. Then fix the code. Either by refactoring out the DSLibrary (guessing that's home grown) or by simply changing it over to using clauses whereever you have database connections made.

更新
还有一件事,改变你的会话属性使用的SQL Server 为后盾存储这样你就不会失去所有的会话信息的应用程序回收。这会买你更多的时间。

update
One more thing, change your session properties to use sql server as the backing store that way you won't lose all the session information as the app recycles. This will buy you more time.

这篇关于为什么把我们的.NET / SQL Server的网站到一个新的主机导致连接池的大小被超过?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆