w3wp.exe 崩溃导致 SQL Server 超时

发布于 2024-09-26 23:27:38 字数 828 浏览 1 评论 0原文

我的网站一直存在问题,W3wp.exe 崩溃,任何尝试连接到该网站的人都会收到 SQL 服务器超时错误。

错误是这样的...

System.Data.SqlClient.SqlException:超时已过期。操作完成之前超时时间已过,或者服务器未响应。

实际情况是,当发生这种情况时,服务器上的 CPU 使用率会达到 100%,并保持在该水平。在此期间,如果我尝试连接到主页,该网站将显示正在加载,然后超时。当我尝试通过管理工作室连接到数据库时也是这种情况。 当 ELMAH 通过电子邮件向我发送异常时,我收到了上述 SQL 超时错误。当我执行 iisreset 时,我可以再次连接到 SQL Server,并且 CPU 使用率立即下降。

现在我已经在这里发布了一些关于 SQL 超时异常的问题。因此,我将列出我所做的以及正在使用的内容...

• 我正在使用 Linq to SQL。 • SQLCacheDependency。 • IIS 7.5 和 IIS 7.5 SQL Server 2008 R2。 • 处理掉所有物品。 • 对Linq to SQL dataContext 的调用始终包含在USING 关键字中。

这些超时错误很少发生,可能每两天一次,但今天当我起床时,我的收件箱充满了超时异常,表明夜间发生了一次。

另一个奇怪的事情是,例如,昨晚发生这种情况时,时间是凌晨 4 点左右,当我今天早上 8 点尝试时,该网站工作正常,所以我觉得 W3wp.exe、SQL 服务器或两者都超时了,要么设法回收或自行重置。

任何人都可以看到可能导致这种行为的原因吗?或者指出我可能的原因的正确方向?或者甚至可能是一个可能的解决方案?

非常感谢

Truegilly的任何帮助

I have a ongoing issue with my website, where it appears the W3wp.exe crashes and in turn anyone attempting to connect to the site will receive a SQL server timeout error.

The error is this...

System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

What actually happens is when this occurs, the CPU usage on the server maxes out to 100% and stays there. During this time if I try and connect to the homepage the site will appear to be loading and then timeout. This is also the case when i try and connect to the database through management studio.
I get the above SQL timeout error from ELMAH when it emails me exceptions. When I do a iisreset I can once again connect to SQL server and the CPU usage drops immediately.

Now I have already posted a few questions oh here about the issue in regards to the SQL time out exception. So ill list what I have done and what im using...

• Im using Linq to SQL.
• SQLCacheDependancy.
• IIS 7.5 & SQL Server 2008 R2.
• Disposing of all objects.
• The call to the Linq to SQL dataContext is always wrapped in a USING Keyword.

These timeout errors occur infrequently, maybe once every 2 days, but today when I got up, my inbox was full of time out exceptions indicating one occurred overnight.

The other odd thing is that when for example it happened last night, it was around 4am, when I tried it this morning at 8am the site worked fine, so I appears that overtime the W3wp.exe, SQL server or both manage to either recycle or reset themselves.

Can anyone see what maybe causing this behaviour ? or point me in the right direction of what maybe the cause ? or perhaps even a possible solution ?

Any help is most appreciated

Truegilly

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一桥轻雨一伞开 2024-10-03 23:27:38

我猜测超时是因为 CPU 峰值较高,而不是相反。如果您的 IIS 和 SQL 在同一台计算机上,请尝试找出占用处理器的进程(从任务管理器)。

如果是 Web 服务器,请设置执行计数器,尤其是与 .NET 垃圾收集相关的计数器,并查看其执行频率。另请检查 Gen2 对象大小。您必须从运行良好时开始收集这些数据,直到 CPU 达到最大,并比较计数器中“增长”的数据。检查您是否在数据上下文中启用了对象跟踪,以及您的 using(datacontext){ ... } 有多长。

如果是 sqlserver 占用 CPU,请尝试使用 以下 Microsoft 文章来分析这个问题。

I would guess the timeout is because of the high CPU spike, not the other way round. If your IIS and SQL are on the same machine, try to find out the process (from task manager) which is hogging the processor.

If it is the web server, setup perform counters, especially the ones related to .NET Garbage collection, and see how frequently it is getting executed. Also check the Gen2 object size. You would have to collect this data starting from when it is running fine till CPU maxes out, and compare what is "growing" in the counters. Check if you have object tracking enabled in the data context, and also how long your using(datacontext){ ... } are.

If it is the sqlserver that is holding the CPU, then try to use the following Microsoft article to analyze the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文