情况: ASP.NET 实时网站有时太忙。
在代码中添加完整的分析会对性能产生太大的影响。使用性能监视器,我们很快就在“所有堆中的字节数”计数器中找到了锯齿形数字,该计数器与 GC 计数器配对。我们认为某些代码片段是罪魁祸首。
对于某些页面、库、函数或其他什么,是否有办法或可能临时“注入”分析?最好尽可能轻,因为任何额外的开销都可能导致这个脆弱的系统崩溃。我知道 .NET 不支持方法回调挂钩(这在 AOP 中很常见)。
Situation: ASP.NET live website that's occasionally too busy.
Adding full profiling to the code will be too heavy an impact on the performance. Using performance monitor, we've quickly find a saw-teeth figure in the "bytes in all heaps" counter, which pair with the GC counters. We consider certain pieces of code as being the culprit.
Is there a way or possibility to temporarily "inject" profiling, either for certain pages, libs, functions or whatever? Preferably as lightweight as possible, as any additional overhead might bring down this fragile system. I'm aware that .NET does not support method callback hooks (as is common with AOP).
发布评论
评论(4)
一些想法:
如果它有帮助,您可能还对我书中的性能提示感兴趣:Ultra-快速 ASP.NET。
编辑:您还可以尝试使用 .NET Memory Profiler(提供免费试用)来附加到正在运行的进程。与计数器相比,它具有相当大的侵入性,但如果您需要捕获当前内存状态的快照来调试问题,可能没有更好的选择。
A few ideas:
In case it's helpful, you might also be interested in the performance tips from my book: Ultra-Fast ASP.NET.
Edit: you might also try using .NET Memory Profiler (free trial available) to attach to the running process. It's fairly invasive compared to counters, but if you need to capture a snapshot of the current state of memory to debug your problem, there may not be a better choice.
是的,您可以在应用程序运行时获取应用程序的内存转储并查看其内容保存在记忆中。这应该会强化或否定你的假设。
Yes, you can take a memory dump of the application as it's running and see what it's holding in memory. This should reinforce or deny your assumptions.
我最近针对类似的挑战发布了一个可能的解决方案:
分析多层、分布式 Web 应用程序(服务器端) 显示了一种高级方法(在 URL 级别进行分析),即:
这个想法是使用现有网络日志并将其转换为“一张图片相当于 1000 个单词”类型图表。
这种方法对于需要更精细细节的用例来说是不够的,但它对我个人有帮助,并且可能值得在您的案例中探索。
I recently posted a possible solution to a similar challenge:
Profiling a multi-tiered, distributed, web application (server side) shows a high level approach (profiling on the URL level) that is:
The idea is to use existing web logs and convert them into a "one-picture is worth a 1000 words" kind of chart.
This approach is not sufficient for use-cases requiring more fine-level detail, but it helped me personally, and may be worth exploring in your case.
你能做到这个 在 ASP .NET 上?这是了解正在发生的情况的快速方法。
Can you do this on ASP .NET? It's a good quick way to find out what's going on.