W3WP.EXE 使用 100% CPU - 从哪里开始?

发布于 2024-08-17 19:25:57 字数 253 浏览 13 评论 0原文

在 IIS6 上运行的 ASP.NET Web 应用程序会定期使 CPU 达到 100%。在这些事件中,几乎所有的 CPU 使用情况都是由 W3WP 负责的。 CPU 在几分钟到一个多小时的任何时间都保持在 100%。

这是在临时服务器上,此时该站点仅从测试人员那里获得了很少的流量。

我们已经在服务器上运行了 ANTS profiler,但效果并不理想。

我们可以从哪里开始找出导致这些事件的原因以及哪些代码在这段时间内使 CPU 保持忙碌?

An ASP.NET web app running on IIS6 periodically shoots the CPU up to 100%. It's the W3WP that's responsible for nearly all CPU usage during these episodes. The CPU stays pinned at 100% anywhere from a few minutes to over an hour.

This is on a staging server and the site is only getting very light traffic from testers at this point.

We've running ANTS profiler on the server, but it's been unenlightening.

Where can we start finding out what's causing these episodes and what code is keeping the CPU busy during all that time?

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

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

发布评论

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

评论(9

对不⑦ 2024-08-24 19:25:57
  1. 标准 Windows 性能计数器(查找其他相关活动,例如许多 GET 请求、过多的网络或磁盘 I/O 等);您可以从代码以及 perfmon 中读取它们(例如,如果 CPU 使用率超过阈值,则触发数据收集)
  2. 自定义性能计数器(特别是对开箱请求和执行时间不确定的其他调用的时间)
  3. 负载测试,使用 Visual Studio Team Test 或 WCAT 等工具
  4. 如果您可以在 IIS 7 上进行测试或升级到 IIS 7,则可以配置失败请求跟踪,以便在请求花费超过一定时间的情况下生成跟踪
  5. 使用 logparser 查看当时到达的请求CPU 峰值的
  6. 代码审查/演练(特别是查找可能无法正确终止的循环,例如发生错误,以及锁定和潜在的线程问题,例如静态的使用)
  7. CPU 和内存分析(在生产系统上可能很困难)
  8. Process Explorer
  9. Windows 资源监视器
  10. 详细的错误日志记录
  11. 自定义跟踪日志记录,包括执行时间详细信息(可能是有条件的,基于 CPU 使用性能计数器)
  12. AppPool 回收时是否发生错误?如果是这样,这可能是一个线索。
  1. Standard Windows performance counters (look for other correlated activity, such as many GET requests, excessive network or disk I/O, etc); you can read them from code as well as from perfmon (to trigger data collection if CPU use exceeds a threshold, for example)
  2. Custom performance counters (particularly to time for off-box requests and other calls where execution time is uncertain)
  3. Load testing, using tools such as Visual Studio Team Test or WCAT
  4. If you can test on or upgrade to IIS 7, you can configure Failed Request Tracing to generate a trace if requests take more a certain amount of time
  5. Use logparser to see which requests arrived at the time of the CPU spike
  6. Code reviews / walk-throughs (in particular, look for loops that may not terminate properly, such as if an error happens, as well as locks and potential threading issues, such as the use of statics)
  7. CPU and memory profiling (can be difficult on a production system)
  8. Process Explorer
  9. Windows Resource Monitor
  10. Detailed error logging
  11. Custom trace logging, including execution time details (perhaps conditional, based on the CPU-use perf counter)
  12. Are the errors happening when the AppPool recycles? If so, it could be a clue.
ζ澈沫 2024-08-24 19:25:57

这并不是一个很好的答案,但您可能需要采用传统方式捕获 IIS 进程的映像快照并对其进行调试。您可能还想查看 Tess Ferrandez 的博客 - 她是一位出色的 Microsoft 升级工程师,她的博客重点关注调试 Windows ASP.NET,但该博客总体上与 Windows 调试相关。如果您选择 ASP.NET 标记(这就是我链接到的标记),那么您将看到几个类似的项目。

It's not much of an answer, but you might need to go old school and capture an image snapshot of the IIS process and debug it. You might also want to check out Tess Ferrandez's blog - she is a kick a** microsoft escalation engineer and her blog focuses on debugging windows ASP.NET, but the blog is relevant to windows debugging in general. If you select the ASP.NET tag (which is what I've linked to) then you'll see several items that are similar.

回首观望 2024-08-24 19:25:57

如果您的 CPU 峰值达到 100% 并保持在该水平,则很可能出现死锁情况或无限循环。分析器似乎是查找无限循环的不错选择。然而,追踪死锁要困难得多。

If your CPU is spiking to 100% and staying there, it's quite likely that you either have a deadlock scenario or an infinite loop. A profiler seems like a good choice for finding an infinite loop. Deadlocks are much more difficult to track down, however.

故事未完 2024-08-24 19:25:57

ProcessExplorer 是一个出色的故障排除工具。您可以尝试查找CPU使用率高的问题。它可以让您深入了解应用程序的工作方式。

您还可以尝试 Procdump 转储进程并分析到底发生了什么在CPU上。

Process Explorer is an excellent tool for troubleshooting. You can try it for finding the problem of high CPU usage. It gives you an insight into the way your application works.

You can also try Procdump to dump the process and analyze what really happened on the CPU.

寄居人 2024-08-24 19:25:57

我们在一个递归查询中遇到了这个问题,该查询将大量数据转储到输出中 - 您是否仔细检查了所有内容是否退出并且不存在无限循环?

可能会尝试用单个页面缩小范围 - 我们发现 ANTS 在同样的情况下也没有多大帮助 - 我们最终做的是运行该网站,点击一个页面,观察 CPU - 点击下一个页面,观察 CPU - 非常有条理并且耗时,但如果您无法通过一些代码跟踪找到它,您可能会运气不佳 -

我们能够使用 IIS 日志文件将其跟踪到一组可疑的页面 -

希望有所帮助!

We had this on a recursive query that was dumping tons of data to the output - have you double checked everything does exit and no infinite loops exist?

Might try to narrow it down with a single page - we found ANTS to not be much help in that same case either - what we ended up doing was running the site hit a page watch the CPU - hit the next page watch CPU - very methodical and time consuming but if you cant find it with some code tracing you might be out of luck -

We were able to use IIS log files to track it to a set of pages that were suspect -

Hope that helps !

知你几分 2024-08-24 19:25:57

这充其量只是猜测,但也许您的开发团队正在调试模式而不是发布模式下构建和部署应用程序。这将导致.pdb 文件的出现。这意味着您的应用程序将在系统执行期间占用额外的资源来收集系统状态和调试信息,从而导致更多的处理器利用率。

因此,确保它们在发布模式下构建和部署就足够简单了。

This is a guess at best, but perhaps your development team is building and deploying the application in debug mode, in stead of release mode. This will cause the occurrence of .pdb files. The implication of this is that your application will take up additional resources to collect system state and debugging information during the execution of your system, causing more processor utilization.

So, it would be simple enough to ensure that they are building and deploying in release mode.

⊕婉儿 2024-08-24 19:25:57

我知道这是一篇很老的帖子,但这也是一个常见问题。所有建议的方法都非常好,但它们总是指向一个进程,并且很可能我们已经知道我们的网站出现了问题,但我们只想知道哪个特定页面在处理上花费了太多时间。
我认为最精确和简单的工具是 IIS 本身。

  1. 只需在 IIS 左侧窗格中单击您的服务器即可。
  2. 单击主窗格中的“工作进程”。您已经看到哪个应用程序池占用了过多的 CPU。
  3. 双击该行(最终通过单击“显示全部”刷新)以查看哪些页面消耗了太多 CPU 时间(“已用时间”
    列)在此池中

This is a very old post, I know, but this is also a common problem. All of the suggested methods are very nice but they will always point to a process, and there are many chances that we already know that our site is making problems, but we just want to know what specific page is spending too much time in processing.
The most precise and simple tool in my opinion is IIS itself.

  1. Just click on your server in the left pane of IIS.
  2. Click on 'Worker Processes' in the main pane. you already see what application pool is taking too much CPU.
  3. Double click on this line (eventually refresh by clicking 'Show All') to see what pages consume too much CPU time ('Time elapsed'
    column) in this pool
鸩远一方 2024-08-24 19:25:57

如果您发现加载时间较长的页面,请使用 SharePoint 的 开发者仪表板来查看哪个组件需要时间。

If you identify a page that takes time to load, use SharePoint's Developer Dashboard to see which component takes time.

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