views:

561

answers:

6

I have developed a site using Asp.net C# 3.5 and now I feel that some of the pages are loading reeeaaally slooooow. I now need to start going through the website and try to find out whats making it so slow. But I don't know where to start, whats most likely causing the problem? Where do you usually start when trying to find out what is wrong?

One page that is very slow uses the following:

  • Asp.net C# 3.5
  • AjaxControlToolkit (http://www.asp.net/ajax/AjaxControlToolkit/Samples/)
    • RoundedCornersExtender
    • CollapsiblePanelExtender
  • Two different UpdatePanels
  • 11 connections to a MySql database (one quite heavy, using some unions and inner joins)
  • Most of the connections to the database results in populating FormViews or GridViews, so totally I have 2 formviews and 6 gridviews on the page (every gridview show max 10 items)
  • Can a CSS-file slow down the site? The CSS file I use is about 60kb.

Can using the AjaxControlToolkit make the site slow? Is there a better way to use javascripts on the site?

I understand that it's impossible for you to help me locate the problem with slow load but where you would start to look for the problem? The DataControllers? The AjaxControlToolkit? The sql? Is it an easy way to find out if a query in mysql is slow? And what is slow? Is 0.3s slow for a large query?

As you see I have many questions, maybe you could just help me start working in the right direction, thanks really much for your help!

+1  A: 

My general method when dealing with something like this is always the same. I start removing functionality - javascript/css/include files - until the page becomes more responsive - often i take the page back to minimum complexity and build from here. Adding them back one by one you should be able to identify where your bottleneck is. You can also use tools like (for MySQL) the slow query log to identify problematic queries. Abstracting your queries out and running them in phpmyadmin (or similar) can also help you recognise which queries are problems if this is the case.

I guess the first thing you need to identify is what exactly is "slow" about the page, is it rendering time? load time? identifying this should give you a good starting point.

seengee
A: 

I'd start with checking how long those SQL queries are taking to execute. Not sure what the SQL Profiler type tool for MySql would be called. If that is not the culprit you could create a TraceAttribute as shown here to see how long each of your methods take to execute. If that is not the culprit you could go onto using something like FireBug or Fiddler to see how long each part of your site takes to load and how long each request takes. You could also use Tracing instead of Post Sharp, but when you have a hammer every problem looks like a nail.

Yuriy Faktorovich
+1  A: 

First of all you will need to do some profiling/measuring to find out which part of the application is slow, e.g:

  • long running db queries
  • CPU/memory usage on the web/db server
  • amount of data transferred between web server and client (browser)
  • time it takes to render the pages in the browser (javascript)
M4N
Thanks! I'm at a shared host so I can't see the long running dbs or cpu/memory. But I'll start testing my queries one by one and then I can try with firebug like Yuriy mentioned.
Martin
+3  A: 

You could start adding Trace="True" into your <%@ Page %> directive and see where your pages spent most time; also check your web.config and config debug is disabled.

You can also use Performance Monitor to help you to identify your application main bottlenecks

Rubens Farias
+1  A: 

Don't forget about

ASP.NET Tracing

as probably the first, and simplest thing, to start diagnosing ASP.NET problems.

If you want to get a bit more in-depth, don't forget to try:

ASP.NET Health Monitoring

From what you say, though, personally, I'd look into possibly reducing those database connections. Data access is always a major bottleneck (or can be). 11 connections is quite a lot for a single page, especially if one or more of those connection does "heavy" work as you say. Could the page be split into two or more pages? If the problem is in the rendering of the page, the output from ASP.NET Tracing should help in this regard.

The CSS file, whilst quite large at 60kb, is possibly the least likely culprit as most browsers will cache the CSS file after the first request.

CraigTP
A: 

You can enable Trace="True" and check what is overhead in your page

Also see this thread and check my answer points and other answer as well. hope this will help you determining your problem http://stackoverflow.com/questions/1340218/asp-net-website-slow-on-production-server/1340629#1340629

Muhammad Akhtar