开发者

Tips for making a asp.net web application run faster

开发者 https://www.devze.com 2022-12-15 08:37 出处:网络
What all can we do to make a asp.net web application r开发者_JAVA百科un faster than before. What are all the tweaking required for it ?To make any application run faster, first find out where it\'s sp

What all can we do to make a asp.net web application r开发者_JAVA百科un faster than before. What are all the tweaking required for it ?


To make any application run faster, first find out where it's spending its time, then make it spend less time there. Use a profiler.


A profiler simplifies the process of breaking your application into smaller pieces and then speeding up the individual pieces. You can do that on your own if you can't afford a profiler.

For instance, you say your average response time is 4-5 seconds. That's a long time. What's going on in those 5 seconds? Is it all waiting for the database? You can try running your queries outside of the application to see how long they take. You can run SQL Server Profiler to record your database transactions during a period of time, then running the result through the Database Tuning Wizard. It may have some recommendations for changes to the indexes of the database.

You can use Fiddler, or turn on page tracing to find out whether your pages are too large. Tracing can tell you how long particular phases of page operations are taking. Maybe you're taking to long to render certain pages.

Also, you need to look at the performance of your server. Are you using too much CPU? Too much memory? Are you spending your time with page thrashing, knocking the pages of the ASP.NET worker process out of memory in order to bring in the pages of SQL Server, only to have those pages knocked out when the database query completes and the worker process needs to run again?

Break the problem down into smaller pieces, then fix the pieces.


Caching -- both page and data -- and optimizing data access are probably the key elements to improving performance without changing the hardware. Beyond that you can look at clustering/load balancing to make more resources available.


Performance tuning for ASP.NET is a big subject. In fact, in an attempt to provide a comprehensive answer to your question, I wrote a book about it: Ultra-Fast ASP.NET: Build Ultra-Fast and Ultra-Scalable web sites with ASP.NET and SQL Server.

From a high level:

  • Minimize round-trips, both between the client and server, and between the server and DB
  • Focus on perceived performance
  • Minimize blocking calls
  • Cache at all tiers
  • Optimize disk I/O management
  • Optimize browser object load and rendering order
  • Avoid full page reloads with Ajax, Silverlight and JavaScript
  • Avoid synchronous DB writes
  • Use monitoring and instrumentation
  • Understand how SQL Server manages memory
  • Effective use of partitioning at the data tier

My approach is largely prescriptive, rather than theoretical. You might take a look at the reviews on Amazon for more details about what I mean.


This is a big topic, but the main things that come to mind:

  • keep viewstate size down
  • fewer postbacks. Use javascript to avoid them when possible. The validation controls are a good example of how this can work.
  • have a good caching strategy

There's also non-asp.net-specific things, like these:

  • make sure your database queries aren't bogging you down
  • minimize http requests
  • keep static resources in a separate cookieless domain
  • profile before you spend time optimizing so that you don't waste time optimizing the wrong thing

You might also find this question helpful:
https://stackoverflow.com/questions/72394/what-should-a-developer-know-before-building-a-public-web-site


I agree with caching. ASP.NET does have great built-in caching mechanisms.

I also would recommend profiling the application, like it was already recommended above.

Here's a link to an article about some free .NET profilers, and paid ones too.

http://www.devcurry.com/2009/11/free-net-profilers-and-some-paid-ones.html

edit: you might want to check out this StackOverflow thread as well

https://stackoverflow.com/questions/308816/any-good-free-net-profiler

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号