Yazılım Notları
Bilgi Paylaştıkça Çoğalır...

how to enhance the performance of ASP.net Application

How can you enhance the performance of an ASP.NET Application via SQL Server Session State and IIS. Best Practice… Read More…

We can summarize the key factors which is to be focused on, when an ASP.NET application is being developed:

  1. First of all, business analysis has to be well done.
  2. Database design is very important key factor which is better to design according to the database normalization rules. On the other hand, if we are talking about reporting we can also think of denormalization rules on database.
  3. It is a performance enhancer that having enough and sufficient indexes on database tables. On these indexes, fragmentation ratios can be high in time. That’s why, it is recommended to rebuild these indexes as time passes. Generally, if the fragmentation ratio is higher than % 36, it is better to rebuild the index.
  4. If you use many indexes which you dont need indeed, when you INSERT into these tables from your application perfomance of the application will be affected badly. That’s why, you must be careful while you create indexes.
  5. While you are developing the software, you must have done all the unit tests.
  6. Generally it can recommend that not to carry all the variables or even objects on the in proc session.
  7. If you develop a complex software application which is consisted of many modules, you must design well. If you dont, even a very small code block can postback whole pages!

Case Study: Let’s think of a web based software application which has following handicaps:

  1. An ASP.NET Software application which is used to get Project Applications countrywide. This application uses such a system that firstly applicant sign up and fill the application web forms.
  2. Business analysis is done very badly.
  3. Database design hasnt be carried out according to database normalization rules.
  4. A web based application.
  5. In software, Ajac Controls have been used widely. However, they are not well managed. That’s why, there are many JavaScript errors. By the way, even if you click a button in order to open a popup panel, whole page and user controls postbacks together.
  6. When you want to sign in to the application, all the objects (approximately 5 MB / applicant, pdf documents are also inquired when the user first signs in) are inqueried from the database (SQL Server 2008 R2) and all these bytes are carried out on the session (in proc).
  7. There are 20 usercontrols and only one webform. All the user controls are embeded in one webform. That’s why, when this webform is loaded all the user controls are also reloaded.
  8. There is no time to improve the software application codes. It is running…

Application Server Hardware(Briefly)

  1. Processors : 4core x 4 = 16 CPU
  2. RAM : 32 GB
  3. Network : 1 Gps


After the first applicant signs in the system, Application Server CPU usage reach to %95 and the second applicant can pass the login form in 2 minutes. And the floowing main webform doesnt work normally. In 10 minutes, approximately 100 applicants start to wait each other’s sign in and CPU usage reaches 100%. No other applicant can sign in at all.




  1. There may be some still open connections. But after examining the code blocks, we didnt find a ADO.NET connection still open.
  2. We could increase the number of application server and try to load balancing. But there must not a necessity for a small number (relatively small) of visitors. Visitor number was expected to be 5000 users/day. This number is not so bigger. So there may be some other problem. That’s why, we didnt increase the number of application servers.
  3. We tried to increase the nummber of CPU. In this time, CPU usage still stays on 95%. That didnt work too.
  4. Last chance: We could increase the number of “Maximum Worker Process” . We tried it, but after a short while, we saw that the application couldn’t carry the in proc session between the different application pools. Each application pool has its own in proc session. However, among the postbacks session was dissapeared. So we had to find a way to carry session between the application pools strictly.
  5. The best way was: SQLServer Session State.


We decided to change session state mode from "in proc" to "SQL Server"


  1. Open Command Prompt
  2. Go to the directory d:\Windows\Microsoft .NET\FrameWork\v2.0.50727
  3. Run the following command
  4. aspnet_regsql -S [Database Server Name / IP Addresss] -U [DB User Name] -P [DB User Password] -ssadd -sstype p
  5. SessionStateDB
  6. Change sessionState tag in web.config according to the following:

    <sessionState mode="InProc" timeout="20" allowCustomSqlDatabase="" allowCustomSqldatabase="true" sqlConnectionstring="Data Source=Database Server Name;User Id=UserName; Password=*******" cookieless="false"></sessionState>

  7. In the application server, open IIS and open the related Application Pool Advanced Settings. Here, increase the number of Maximum Worker Porcess.
  8. Restart the Application on IIS
  9. IIS-Application Pool



  1. Application Server average CPU Usage ratio dropped to % 18.
  2. Loading time of login page dropped 0.1 second
  3. Performance problem was totally solved.



HAPPY ENDS! smiley


Similar Articles

En Güzel Sözler Uygulaması İçin

En Çok Rating Alanlar
Ana Sayfa       Arama       Valid CSS!