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.
To test warm-up functionality we need warm-up script.
- Create new IIS web application.
- Create subfolder and name it as warmup.
- Create file start.php and move it to warmup folder.
- Insert the following script to start.php: <?php
$fp = fopen("start.txt","w");
fwrite($fp, date(‘d.m.Y H:i:s’, time()));
- 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.
- Open your PHP application folder in IIS Manager and click on Application Warm-Up icon.
- On Actions panel click on Settings. You should see window like this.
- Check both checkboxes and click OK.
- On Actions panel click on Add Request.
- 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.
- Open warmup folder in Windows Explorer so you can see files in it.
- Open command prompt in administrative permissions and run iisreset.
- Wait while IIS is up again and look at warmup folder.
- 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.
- Users are not able to access application while it is warming up.
- Warm-up scripts are run under application’s HTTP context.
- 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.
One thought on “IIS Application Warm-Up Module”
Pingback:ASP.NET 4.0: How to use application warm-up class | Gunnar Peipman - Programming Blog