简体   繁体   English

诊断asp.net网站/应用程序池的性能

[英]diagnosing performance of asp.net website / application pool

I am having an issue with a website developed using ASP.Net/C# sometimes taking all the CPU usage (100%) for an indefinite period of time. 我在使用ASP.Net/C#开发的网站上遇到问题,有时会无限期地占用所有CPU使用率(100%)。 Do you have any ideas / tips how one would go about what could be causing such a resource hog? 您有什么想法/提示如何解决可能导致这种资源浪费的问题吗? The website is still responding, so it is not crashed or something like that. 该网站仍在响应,因此没有崩溃或类似情况。

I'm a bit clueless where to start! 我从哪里开始有点头绪!

Thanks! 谢谢!

Start using Performance Counters on the server. 开始在服务器上使用性​​能计数器。 Add the counters for Garbage Collection, Threads usage and see exactly which thread is consuming the CPU. 添加用于垃圾回收,线程使用情况的计数器,并确切查看哪个线程正在消耗CPU。

Also, check out this: 另外,请检查以下内容:

http://weblogs.asp.net/jgalloway/archive/2009/04/09/troubleshooting-an-intermittent-net-high-cpu-problem.aspx http://weblogs.asp.net/jgalloway/archive/2009/04/09/troubleshooting-an-intermittent-net-high-cpu-problem.aspx

DebugDiag是一个不错的起点: http : //www.microsoft.com/download/en/details.aspx?id= 26798

I had a same issue in Past. 我在过去也遇到过同样的问题。 I mainly had problems with HTML rendering very slow . 我主要遇到HTML rendering很慢的问题。 I resolved it by setting the Trace = true in page directive and found out the event which were taking time. 我通过在页面指令中设置Trace = true来解决此问题,并找出了花费时间的事件。

Another issue was the Memory Management . 另一个问题是Memory Management I was using Image Classes and did not Dispose them properly. 我正在使用Image Classes ,但未正确Dispose它们。 For that I started to use Dispose() method and I can have Using statements in the architecture. 为此,我开始使用Dispose()方法,并且在体系结构中可以使用Using语句。

using (SqlConnection con = new SqlConnection("Connection String"))
{
    using (SqlCommand cmd = new SqlCommand())
    {
        using (SqlDataReader DR = cmd.ExecuteReader())
        {

        }
        using (DataTable DT = new DataTable())
        {
        }
    }
}

I assume you may have any page where you may be fetching records in excess. 我认为您可能在任何页面上都可能获取过多的记录。 You can start to use Paging . 您可以开始使用Paging

The most important point is Exception Handling . 最重要的一点是Exception Handling Try Catch block should not be in every layer. Try Catch块不应该在每一层。 It should be in Presentation Layer only. 它应该仅在Presentation Layer Reason being, when exception occurs, it goes back to the calling function directly. 原因是,发生异常时,它直接返回到调用函数。 So why to write Try Catch block and thus stopping the execution in each layer 那么为什么要编写Try Catch块,从而stopping the execution每一层stopping the execution

Far the best and easiest starting point is to use performance profiler. 最好和最简单的起点是使用性能分析器。 Just run it and with a bit of luck you'll have problem fixed in minutes. 只需运行它,幸运的话,您会在几分钟内解决问题。

Try dotTrace , it's a quite good one. 尝试dotTrace ,这是一个很好的选择。 If you follow the link, there is 10 days free trial and video tutorial. 如果您点击链接,则有10天的免费试用和视频教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM