Share via


Use FREE Tools From IIS Resource Kit To Warm Up Your ASP.NET 1.1 Application By Batch Compilation

Have you noticed that when ASP.NET web application is accessed for the first time the response is slow? The reason for such behavior is batch compilation that occurs on the first hit.

ASP.NET batch compilation is the process of compiling ASP.NET markup (content of aspx files) into temporary dll’s. Compilation requires invoking compiler (csc.exe for C#) – that is pretty heavy activity. Process Explorer shows it clearly:

ASP.NET Batch compilation

ASP.NET batch compilation occurs on per folder basis. Said that, if your application divided into multiple sub-folders that contain ASP.NET pages each time any of the folders accessed for the first time the batch compilation is invoked.

Note that starting with ASP.NET 2.0 compilation model has changed. Also, there is a tool Aspnet_compiler.exe that allows pre-compile your ASP.NET web application to improve performance.

Customer’s case study

Customer’s web application is built with ASP.NET 1.1. It is divided into multiple subfolders reflecting logical modules that are hosted across about 20 application pools. The application connects to Oracle database.

QA team complains that the application responds slowly each time any of the modules (subfolders) accessed for the first time.

Using Process Explorer and profiler we identified three main latency points:

  • Creating the application pool – w3wp.exe.
  • Batch compiling the application for each subfolder.
  • Creating Oracle connection pool when Oracle is accessed for the first time.

The solution

We decided to create a Warmer – solution that will hit each subfolder’s page in unattended manner thus warming up the application before the first user hits it.

For the solution we used free tools from IIS resource kit:

  • LogPrser.exe to identify the URL’s of the pages to hit.
  • TinyGet.exe to actually hit the pages identified by LogParser.

To identify what pages to hit we took IIS log files from QA environment and than we ran the following query using LogParser:

LogParser.exe "SELECT DISTINCT STRCAT('XXX', cs-uri-stem) AS cs-uri-stem-strcat INTO 'C:\result.txt' FROM 'C:\yourIISlogFile.log' WHERE INDEX_OF(cs-uri-stem, 'aspx') > 0" -o:w3c

Notice XXX – it has nothing to do with XXX rated content rather it is a placeholder to replace it with tinyget command.

Open resulting yourIISlogFile.log file in Notepad, hit Ctrl+H for “Replace” and replace all occurrences of XXX with the following command:

tinyget -srv:www.YourServer.com -uri:

ASP.NET Batch Compilation

 

yourIISlogFile.log before the Replace:

image

yourIISlogFile.log after the Replace:

image

Remove the header and save the file with BAT extension  - your Warmer is ready for action. Run it each time you deploy new version.

Do not forget to remove old temporary files in ASP.NET temporary folder:

C:\Windows\Microsoft.NET\Framework\<<NET FX VERSION>>\Temporary ASP.NET Files\

CAUTION. This action may potentially corrupt your application if you do not provide proper exception handling. On one hand it is good check to make. on other hand – be aware of it and do not do it on production sites unless you are completely sure it will not corrupt the application.

Comments

  • Anonymous
    July 31, 2008
    &#160;&#160;&#160;&#160; To achieve best performance you need to make decisions based on trade-off between
  • Anonymous
    July 31, 2008
    &#160;&#160;&#160; In my previous post -&#160; Best ASP.NET Performance Winner For Data Binding - Hands
  • Anonymous
    July 31, 2008
    In my previous post - Best ASP.NET Performance Winner For Data Binding - Hands Up To Response.Write()
  • Anonymous
    September 28, 2008
    Over on the &quot;ACE Team&quot; blog there's a useful blog post with some performance tips for ASP.NET
  • Anonymous
    September 29, 2008
    You've been kicked (a good thing) - Trackback from DotNetKicks.com