diagnosing performance of asp.net website / application pool

耗尽温柔 提交于 2020-01-13 19:45:29

问题


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. 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!


回答1:


DebugDiag is a great place to start: http://www.microsoft.com/download/en/details.aspx?id=26798




回答2:


Start using Performance Counters on the server. Add the counters for Garbage Collection, Threads usage and see exactly which thread is consuming the CPU.

Also, check out this:

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




回答3:


I had a same issue in Past. I mainly had problems with HTML rendering very slow . I resolved it by setting the Trace = true in page directive and found out the event which were taking time.

Another issue was the Memory Management. I was using Image Classes and did not Dispose them properly. For that I started to use Dispose() method and I can have Using statements in the architecture.

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.

The most important point is Exception Handling. Try Catch block should not be in every layer. It should be in Presentation Layer only. 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




回答4:


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. If you follow the link, there is 10 days free trial and video tutorial.



来源:https://stackoverflow.com/questions/9939905/diagnosing-performance-of-asp-net-website-application-pool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!