by Irina Tihova | Apr 06, 2012
In this article you can find some easy steps you can follow to maximize the performance of your ASP.NET applications.
1. Use caching.
When multiple users request the same content from your page, your server can respond with a cached copy of that content. This way, only the first user will have to wait for the actual processing, all the next ones will have the content much faster. In this scenario it’s possible for the user to get old cached content instead of an updated new one. To avoid this use the SQL Cache Dependency. Here’s some information from Microsoft about it: https://msdn.microsoft.com/en-us/library/ms178604.aspx.
You have two options with caching. You can use output caching or partial page fragment caching. The key here is to make a clear separation between the static and dynamic content of your pages.
2. Use compression.
ASP.NET allows you to compress your pages before your server sends them to the client. It uses GZIP compression, which is not very CPU intensive. An easy way to improve the performance of your pages is to enable this feature.
If your application is using SQL queries and they are slow, here are some tips on how to improve that.
3. Use the SQL Profiler and Database Tuning Advisor.
They can be found the SQL Server Performance Tools folder and are useful for the initial diagnostics of the problem. The Profiler is most commonly used with predefined templates for the tests. Sample template you can use is TSQL_Duration. It displays the queries and stored procedures that need much time for execution.
The possible reasons for these too slow queries and procedures are:
– Lack of Indexes – if the databases your application is using are not indexed, index them. This will drastically improve its performance. All the searches in these databases will run much faster.
– Too Much Indexes – if there’s a large number of indexes in the databases, this can also slow your application. So be careful to add enough but not too much indexes to your databases.
– Not Well-Written Queries – if the queries your application is using are poorly written, they can cause severe performance issues as well.
– Deadlocks – the situation where two transactions are in the same state of waiting the other one to finish.
It’s sometimes hard to find all the above issues and correct them, but this is the way for your application to reach its maximum performance.
The following advices can be of use for you when you’re designing your applications.
4. Turn off features that your application won’t take advantage of.
Session State and View State are great features of ASP.NET. They ease your users by allowing the application to save information about their interaction with the site. However, make sure you disable them if you don’t need them. They are turned on by default and can dramatically slow the performance of your application.
Alternatively, you can use the ReadOnly attribute on pages that only need to read the session state. For the View State, you have the options to compress it or to save it to a server to speed up the application’s performance.
5. Make sure your code is compiled before you deploy it.
This way your Web server won’t have to do the compiling while serving other requests.
6. Don’t throw exceptions unless it’s absolutely necessary.
By default, exceptions use a lot of system’s resources. That’s why you need to be careful when designing your applications. You can use Perfmon to monitor the amount of exceptions being thrown by your application. If the value is unacceptable, try to use less exceptions in your code.
7. If Stored Procedures are an option, use them.
They can make your application running much faster. They are not being interpreted, compiled, and transferred between the client and the server. This way, they result in less occupied server and less network traffic.
Category: Website Performance | Tagged No Comments.