a blog for those who code

Monday 28 July 2014

How to improve Asp.Net Application Performance - Part 2

This post is a continuation of How to improve Asp.Net Application Performance - Part 1, where we will show you how using simple tips can improve th performance of your Asp.Net application.

1. Use In-Process Session State

InProc state is considered faster than either the state server or SQL Server session storage techniques. It will perform best because state memory is kept within the ASP.Net process. But, before using it note that with each domain restart Session state is lost. So, keep in mind before using it.

2. Ensure Pages are Batch Compiled

When number of assemblies in a process grows, the virtual address space can become fragmented, thus making out-of-memory exception to occur.

To prevent a large number of assemblies from loading in a process, ASP.NET tries to complie all pages which are in a single directory into a single assembly.

In Web.Config file,

<compilation batch="true"/>

3. Ensure Debug is set to false at page level

Before you run any performance tests on your application make all the debug to false at the page level.

<compilation debug="false" ... />

It is becuase if you dont set debug to false the pages are not batch compiler, page do not time out when any problem occur and also additional files are generated at the temporary ASP.NET Files folder thus make your ASP.NET application little slow.

4. Minimize use of Viewstate

View state is loaded every time the page is loaded that means view state is serialized and deserialized on the server. So, to reduce the CPU cycles, reduce the amount of usage of ViewState in your application. As CPU effort is proportional to the view state size. Disable view state if you do not need it or Minimize the number of objects you store in your View State.

5. Clear the Garbage Collection Explicitly

Yes, we all know that .Net application provide us with Garbage Collection to clean the unused resources from memory, but it takes time to clear the unused objects from memory.

Now if you use objects that implement IDisposable interface, make sure you call the Dispose method of the object. The best place to do is to use Finally block which is explained in the previous blog.

Please Like and Share the Blog, if you find it interesting and helpful.

No comments:

Post a Comment