Asp.net Performance Optimization in Web Sites

Performance Optimization in ASP.NET Web Sites: Performance is an important aspect of the modern day web application development. Not only does it makes a site seamless to use, but also increases the sociability of the website and makes it future proof. In this article, we will look at various aspects of improving the performance of ASP.NET web applications. We will only concentrate on the browser/web server side performance as opposed to server/app server/database server performance optimizations.

Here are some examples on why you would need optimized web sites.


- Amazon.com had performed a test on their web site, and when they slowed the site by 100ms, the sales drop was 1%. As you would imagine for a company like Amazon, 1% is a huge loss.

- Google slowed their Search Engine by 500ms, and the traffic dropped by 20%.

As you can see, performance is a very important aspect of modern web sites. It becomes more important as nowadays most sites require optimized sites for mobile, tablet devices and other portable devices that often run on low throughput wireless networks.

Here are some tips that you can consider while making a better performing website.

Using the right ASP.NET framework:

Check your .NET framework. If you can upgrade your site to use .NET 4.5, then it has some great performance optimizations. .NET 4.5 has a new Garbage Collector which can handle large heap sizes (i.e tens of gigabytes). Some other improvements are Multi-core JIT compilation improvements, and ASP.NET App Suspension. These optimizations do not require code changes. A great article on an overview of performance improvements of .NET 4.5 is at http://msdn.microsoft.com/en-us/magazine/hh882452.aspx

File compression:


There are often requests bloated to the web server with lot of static content. These content can be compressed thereby reducing the bandwidth on requests.

The following setting is only available in II7 and later.

<configuration>
<system.webServer>
  <urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>
</configuration>

The above configuration setting has direct association with IIS and nothing to with ASP.NET. The urlCompression name sounds strange but it is not really the compressing of URLs. It is compressing or gripping the content and that sent to the browser. By setting to true/enabling you can zip content sent to the browser while saving lots of bandwidth. Also notice that the above setting does not only include static content such as CSS/JS, but also dynamic content such as .aspx pages or razor view. 

If your web server is running in Windows Server 2008 R2 (IIS7.5), these settings are enabled by default. For other server environments, you would want to tweak the configuration as I just showed, so that you can take the advantage of compression. 

Reducing the number of requests to the Server
It is very common that lot of websites uses individual CSS files and JS files as static content. Usually each file is served per request. For a small site this seems minimal, but a number of large static files, when requested via the web server, utilize lot of bandwidth over the network. 

ASP.NET provides a great way to bundle and minify these static content files. This way the number of requests to the server can be reduced. 

There are many ways to bundle and minify files.

 For example, MSbuild, third party tools, Bundle Configs etc. But the end result is the same. One of the easiest ways is to use the new Visual Studio Web Essentials Pack



Other Asp.net Related Post :






Comments

  1. This is very nice blog. It’s really very good information for us about ASP.NET framework. It has some information that I really need in my project for better enhancement. A few days before I found this kind of information from Hostbuddy.com. Thank you

    ReplyDelete

Post a Comment

Popular posts from this blog