views:

913

answers:

10

My problem is that my ASP.NET website is running slower on my production server comparatively on my development server.

A page that executes in 120ms in my development environment takes 400ms to execute on the server. I've monitored the SQL server with the profiler and the query being run on the page taking 400ms on the server only takes around 50ms to finish - so I've convinced myself that my problem does not lie with the SQL server.

My development machine is an Intel I7 with 6GB RAM, the production server is a 2x AMD Quad Core with 16GB ram.

+3  A: 

Have you checked that the debug=false in your web.config?

Is the server 64bit? Try to create a dedicated application pool for your application and set the application pool to run in 32bit classic mode. Makes that any difference?

Is you class pre-compiled or have you set it up to compile at runtime?

Magnus Johansson
Oridinarily that would be true on the development wouldn't it?
AnthonyWJones
I've tried changing this value, it doesn't make much of a difference.
cralexns
Added 2 more options in my answer.
Magnus Johansson
I've tried both pre-compiled and just copying the project files over, that only really makes a difference the first time a page runs.Both dev and production is 64bit, not sure exactly what you mean by 32bit classic mode but setting the pipeline to classic throws an exception with a configuration error, telling me it can't find one of my assemblies. I changed Enable 32-Bit Applications to TRUE, it was FALSE before, this seems to have incurred a performance boost, what was ~400ms before is now ~300ms, still not the 120ms of my dev server though.
cralexns
Also changed this on my development machine and it's even faster now but that also means the gab in performance is unchanged. :( Thanks for the tip though! :)
cralexns
I had this same issue -- setting the app pool to 32bit fixed the problem for me. Page load time went from 1.6s to 400ms ! Thank you.
Matthew M.
+2  A: 

Set Trace="true" (<%@ Page Trace="true"...) in your page and you will get a lot of useful information at the bottom of the page when it loads in the browser. You will know exactly how much time is needed to process the request on the server. If the time is low enough, then the problem could be in the IIS settings. Compare them to the ones on your dev environment.

lingvomir
I can see from the trace that the majority of the execution time is from the page load event.
cralexns
what's in the page load event then??
wefwfwefwe
All the logic that runs faster on my development machine :P
cralexns
+1  A: 

Is your SQL server on another server on production, but local on development?

Mike McClelland
The SQL server is running on the same server as the IIS
cralexns
A: 

Massive viewstate causing transmission delay?

Stephen Newman
I've tried disabling ViewState in the web.config, there may be a slight improvement but we're still taking 3x slower execution time on the server compared to the development machine...
cralexns
A: 

Is this the only website you have on the server? 16 GBs is pretty good memory, but if there are many popular websites on that same server they could be eating up the resources and CPU time.

Other than that I can't think of any reason why your website would be slow on production than in development.

Did you check out the indexes? They're all there on the server?

Cyril Gupta
The only thing currently running on the server is this one website.
cralexns
+6  A: 

There are some point you can consider for performance improvment of your website.

  1. Set debug=false
  2. Turn off Tracing unless until required
  3. Turn off Session State, if not required. ASP.NET Manages session state automatically. However, in case you dont require Sessions, disabling it will help in improving the performance
  4. Disable ViewState as and when not required.
  5. Avoid Frequent round trips to the Database
  6. Avoid Throwing Exceptions. Exceptions are a greate way to handle errors that occur in your application logic. However, throwing exceptions is a costly resource and must be avoided. Use specific exceptions and use as minimal as possible to avoid resource overhead
  7. Use Caching to improve the performance of your application.
  8. Use Finally Method to kill resources

Edit: measure your website performance using this website http://www.websiteoptimization.com/services/analyze/
http://www.websitepulse.com/

Muhammad Akhtar
Those are all great tips for sure but before optimizing anything I would like my server to actually perform somewhat close to what my dev machine does, and not be up to 3 times slower - which is ridiculous!
cralexns
A: 

For the connection string on the production environment, are you using (local) or the machine name or the IP address?

twlichty
The SQL server is local and the connection string is defined with localhost/INSTANCENAME, integrated.
cralexns
A: 

You need to reduce the variables.

Try eliminating all of the differences between the two environments, then make changes one by one until you figure out what it is.

Make sure that the web.config is the same in both environments.
Make sure both environments point to the same database server on a 3rd box.
Make sure the same version of IIS is in both environments.
Make sure IIS is configured the same in both environments.
Run the same test data on both environments.
etc...

Greg
I'm trying but I'm at a loss on what more I can do at this point, I can check off everything on your list apart from running the database on a third server since that isn't an option for me.
cralexns
+1  A: 

From reading all the suggestions, and it seemingly like nothing is working, start taking code out of your site, little by little, and see how that affects time. Remove about 10 lines of code or HTML at a time, and see if there is a huge difference.

Otherwise, it probably has to do with IIS, and sorry, I ain't no IIS guru.

Martin
I've tried removing certain performance intensive functions from the website and while it obviously improves the performance not to have those it seems like the server is just generally slower at executing code, regardless.. Though, I did conduct a simple for loop test (commented this on my original post) where the server would handle the simple loop faster than my development machine, 10 million iteractions was faster on the production machine - but as soon as I was called some function residing in my class library the production server would be slower..
cralexns
A: 

After banging my head against the wall for a long time concerning the performance difference of my development machine and the production machine, I finally caved in to the feeling I've been having deep down that the processor actually matter a lot more than you'd think.

I changed from an AMD based solution to an Intel based solution (Xeon!), gaining .3GHz and faster disks.

I also gained a performance boost, instead of being x3 as slow as my development machine it's now down to something like x0.75 slower - obviously still not the lightning speeds that my development machine is capable of but it's getting closer.

While debugging this further I noticed that most of the performance hog (which is no surprise really) is coming from LINQ to SQL having to compile queries, what seems odd to me is that once I tried precompiling a LINQ query and running the same thing on both my machines, the development machine turned out to be faster.

cralexns
I would think that the performance gain from switching from 'debug' to 'producion' would outweigh any negative processor difference.
UpTheCreek