X

IIS Application Warm-Up Module

During one of my sessions I demonstrated how to use IIS Application Warm-Up Module. Some applications need to perform initialization tasks before taking requests from users. Application warm-up module is very good tool for this because it does not depend on script language or any other aspect of web application. In this posting I will show you how to use application warm-up module with simple PHP script.

To get PHP up under IIS I suggest you to follow the guide on IIS website Using FastCGI to Host PHP Applications on IIS 7.0. It applies to IIS 7.5 too. And, of course, you have to install Application Warm-Up Module.

Creating test-application

To test warm-up functionality we need warm-up script.

  1. Create new IIS web application.
  2. Create subfolder and name it as warmup.
  3. Create file start.php and move it to warmup folder.
  4. Insert the following script to start.php: <?php 
      
    $fp = fopen("start.txt","w"); 
    fwrite($fp, date(‘d.m.Y H:i:s’, time())); 
    fclose($fp); 
      
    ?>
  5. Save file and close it.

In this point I recommend you to make warmup folder unaccessible from other machines. You can easily force IP-based rule that allows requests to this folder only from 127.0.0.1.

Registering start-up script

Now let’s make start.php run when application starts.

  1. Open your PHP application folder in IIS Manager and click on Application Warm-Up icon.
  2. On Actions panel click on Settings. You should see window like this.
  3. Check both checkboxes and click OK.
  4. On Actions panel click on Add Request.
  5. Insert location of your warm-up script to URL field (like shown on screenshot above) and click OK.

Now we have warm-up script registered and we are ready to test it.

Testing application warm-up

Now you have warm-up script that creates new file with current date in the same folder. I suggest you to open Event Viewer so you can easily see error messages if there are any problems.

  1. Open warmup folder in Windows Explorer so you can see files in it.
  2. Open command prompt in administrative permissions and run iisreset.
  3. Wait while IIS is up again and look at warmup folder.
  4. You should see file called start.txt there.

Why application warm-up with warm-up module?

Using application warm-up module has some very important advantages.

  1. Users are not able to access application while it is warming up.
  2. Warm-up scripts are run under application’s HTTP context.
  3. Application warm-up module knows only requests it must send but it is not aware of scripting language or technology behind those requests.

ASP.NET 4.0 has also the other mechanism for application warm-up.

Liked this post? Empower your friends by sharing it!
Categories: IIS

View Comments (0)

Related Post