- Viewstate
View state is wonder mechanism which shows the details of entry which posted on the server. Every time its get loaded from the server. This option looks like extra feature for the end users. This needs to be loaded from the server and it adds more size to the page But it will affect the performance when we have many controls in the page like user registration. So, if it is no need then it can be disabled.
EnableViewState = "false" needs to be given based on the requirement. It can be given at the control, page and config level settings.
- Avoid Session and Application Variables
Session is storage mechanism which helps the developers to take the value across the pages. It will be stored based on the session state chosen. By default it will be stored in the Inproc. That default settings uses the IIS. When use this Session variable in a page, which is accessed by many numbers then it will occupy more memory allocation and gives addition overhead to the IIS. It will make the slow performance.
Most of the scenarios it can be avoided. If you want to send the information across the pages then we can use Cross Post back, Query string with encrypted. If you want to store the information with in the page, then cache object is best way.
- Use Caching
ASP.Net has the very significant feature of caching mechanism. It gives more performance and avoids the client/server process. There are three types of caching in ASP.Net.
If there is any static content in the full pages then it should be used the Output cache. What it does, it stores the content on IIS. When the page is request it will load immediately from the IIS for the certain period of time. Similarly Fragment paging can be used for store the part of web page.
- Effectively use CSS and Script files
If you have big CSS files which used for the entire site different pages, then based on the requirement it can be spitted and stored with different names. It will minimize the loading time of the pages.
- Images sizes
Over use of images in the web site affect the web page performance. It takes time to load the images especially on dial up connections. Instead of using the background images, it can be achieved on the CSS colors or use light weight images to repeat in the entire pages.
- CSS based layout
The entire web page design controlled by the CSS using the div tags instead of table layout. It increases the page loading performance dramatically. It will help to enforce same standard guideline throughout the website. It will reduce the future changes easily. When we use the nested table layout it takes more time for rendering.
- Avoid Round trips
We can avoid unnecessary database hits to load the unchanged content in the database. We should use IsPostBack method to avoid round trips to database.
- Validate using JavaScript
Manual validation can be done at the client browser instead of doing at the server side. The JavaScript help us to do the validation at the client side. This will reduce the additional overhead to the server.
The plug-in software helps to disable the coding in the client browser. So, the sensitive application should to the server side validation before go into the process.
- Clear the Garbage Collection
Normally .Net application use the Garbage collection to clean the unused the resources from the memory. But it takes own time to clear the unused objects from the memory.
There are lots of ways to clean the unused the resource. But not all the methods recommended. But we can use dispose method in the finally block to clean the resources. More over we have to close the connection. It will immediately free the resources and gives spaces in the memory.
- Avoid bulk data store on client side
Try to avoid more data on the client side. It will affect the web page loading. When we store more data on the hidden control then it will encrypt and store on the client side. It can be tamper by hackers as well.
- Implement Dynamic Paging
When we load bulk number of records in server data controls like GridView, DataList, and ListView it will take time to load. So we can show only the current page data through the dynamic paging.
- Use Stored Procedure
Try to use stored procedure maximum. It will increase the performance of the web pages. Because it is stored as complied object in the database and it uses the query execution plans. If you pass the query then it will make network query. In the stored procedure single line will be passed to the backend.
- Use XML and XSLT
XML and XSLT will speed up the page performance. If the process is not more complex then it can be implemented in XSLT.
- Use Dataset
The DataSet is not light weight when compare with DataReader. But it has the advantages of disconnected oriented architecture. The DataSet will consume lot of memory. Even though it can have more than one day. If you want to perform many operations while loading the page itself, then you can better go with DataSet. Once data is loaded into DataSet then it can be used later also.
- Use String Builder in place of String
When we append the strings like mail formatting in server side, then we can use String Builder. If you use string for concatenation, what it does every time it create the new storage location for place that string. It occupies more spaces in memory. But if we use String Builder class in C# it consumes more memory space than String.
- Use Server.Transfer
If you want to transfer the page with in the current server then we can use the Server.Transfer method. It avoids roundtrips between the browser and server. But it won't update the browser history.
- Use Threads
Thread is important mechanism in the programming language to utilize the system resources effectively. When we want to do background process then it can be called as background process.
Consider an example, when click on send, it should sends the mail to 5 lakhs members that time no need to wait for all the process completion. Just call the mail sending process as background thread then go ahead for the further process. Because this mail sending not depend on the any other process.
Saturday, August 29, 2009
Tips to improve the performance in ASP.Net application
Here are few tips to improve the performance of your web application.
Subscribe to:
Comments (Atom)
