IIS Compression Features Will Save You Money!

Compression has been a feature that has been with IIS for quite sometime. But many in us seem completely oblivious to its existence given its performance advances & savings through lower bandwidth! For Starters Bandwidth is costlier than CPU.

With IIS 6 people experienced upwards of 4 times the compression which directly translates to bandwidth savings and ofcourse faster loading of pages for the end user also. Things, as we will see, has only gotten better with IIS 7.

Lets get our hands dirty and learn something and leave this small(read business) talk to lazy people shall we?

With IIS 6, back-up the IIS metabase before you do anything. Metabase is a sensitive/dangerous yet a powerful file and Its always good to have a configuration backup handy just in case.

The actual Compression configuration can be done as follows:
From the IIS snap-in,
- Right-click on the Web Sites node and click on Properties
- Select the Service tab
- Enable Compress application files
- Enable Compress static files
- Change Temporary Directory to the folder that you created above, or leave it at it's default(make sure the destination directory has the right security access)
- Set the max size of the temp folder to something that the hard drive can handle. i.e. 1000
- Save and close the Web Site Properties dialog

Changes in the IIS Metabase directly, pls be careful with the file
- Open the metabase located at C:\Windows\system32\inetsrv\metabase.xml in Notepad
- Search for IIsCompressionScheme
- There should be two of them, one for deflate and one for gzip. Basically they are two means of compression that IIS supports.
- First thing to do is add aspx, asmx, php and any other extension that you need to the list extensions in HcScriptFileExtensions. Make sure to follow the existing format carefully, an extra space will keep this from working correctly. Do this for both deflate and gzip.
- HcDynamicCompressionLevel has a default value of 0. Basically this means at if you did everything else right, the compression for dynamic contact is at the lowest level. The valid range for this is from 0 to 10.
- Reset IIS

And you have the compression up & running on your IIS!

The differences between IIS 7 & IIS 6 regarding the Compression feature:
Instead of compression per extension as in IIS 6, it's per mime type with IIS 7. Additionally, it's easier to enable or disable compression per server/site/folder/file in IIS 7. It's configurable from IIS Manager, Appcmd.exe, web.config and all programming APIs.

Additionally, IIS 7 gives the cool ability to have compression automatically stopped when the CPU on the server is above a set threshold. This means that when CPU is freely available, compression will be applied, but when CPU isn't available, it is temporarily disabled so that it won't overburden the server.

Trade-Offs using the Compression feature with IIS is that
  • as you increase the levels compression (0 to 10) the Time to first byte and CPU util increases while the transactions per second nose dives.
  • Static files are compressed once and cached, so you could use a higher compression level with them.
  • But the dynamic you have a lot more to consider. If you have a server that isn't CPU heavy, and you actively administer the server, then crank up the level as far as it will go. If you are worried that you'll forget about compression in the future when the server gets busier, and you want a safe setting that you can set and forget, then leave at the default of 0, or move to 4.
  • Make sure that you don't compress non-compressible large files like JPG, GIF, EXE, ZIP. Their native format already compresses them, and the extra attempts to compress them will use up valuable system resources, for little or no benefit.
Leave a comment on your impressions of this article, so that we can do a follow-up post if needed.

Bookmark and Share


Post a Comment