:::: MENU ::::

Monday, April 28, 2008

Compression is a very "cheap and easy" way to improve responsiveness of your site. Here is an excerpt from an excellent white paper: High Performance Web Sites: The Importance of Front-End Performance

There are three main reasons why front-end performance is the place to start.

  1. There is more potential for improvement by focusing on the front-end. Cutting it in half reduces response times by 40% or more, whereas cutting back-end performance in half results in less than a 10% reduction.
  2. Front-end improvements typically require less time and resources than back-end projects (redesigning application architecture and code, finding and optimizing critical code paths, adding or modifying hardware, distributing databases, etc.).
  3. Front-end performance tuning has been proven to work. Over fifty teams at Yahoo! have reduced their end-user response times by following our performance best practices, often by 25% or more.

Here is the link to a post that contains PDF and PPT: http://nate.koechley.com/blog/2007/06/12/high-performance-web-sites/, or slideshare link: http://www.slideshare.net/techdude/high-performance-web-sites/

Compression is number 4 out of 14 Rules.

————————————–

Steps below are for enabling compression in IIS6.

I found very good instructions around this subject here: Scott Forsyth's post, but I am a visual person and decided to add some screenshots to make this process easier when I have to repeat it in the future.

Please refer to Scott's post for background information about compression and compression in IIS6 specifically.

Steps below are required because IIS6 doesn't have an easy to use interface, but provides all the necessary functionality through its metabase. You can think of metabase as registry for IIS6. All the settings that you see in IIS Manager and all those that you do not see can be confugred using metabase. The good news is that in IIS6 metabase is an XML file that can be modified with a Notepad. And just like with registry, you have to be very careful when making changes — and definitely BACKUP before starting.

  • Backup the metabase:
    1. Open up IIS Manager
    2. Right-click on the Server node
    3. Choose All Tasks -> Backup/Restore Configuration
    4. Follow the screens
    5. The good news it looks like IIS automatically backups the metabase
  • Before enabling compression on your site, take some baseline measurements to see how much bandwidth you will be saving (you and your users)
    • If you haven't played with Fiddler, you should spend some time with it.
    • It is an excellent tool for seeing exactly what your application (in most cases Browser) requests, amount of information coming back, time it takes, etc
    • I provide stats towards the bottom of this post
  • Enable Compression within IIS Manager
    • Unfortunately setting only these settings is not enough but required nonetheless
    • IIS Manager, right click on "Web Sites" node and choose properties
    • "Service" Tab, check
      • "Compress application files"
      • "Compress static fiels"
    • You should set max size to make sure you don't run out of space. IIS6 allows a max of 1024MB
    • Default location of compressed files is "%windir%¥IIS Temporary Compressed Files". Scott mentions that IUSR_{machinename} needs to have Write rights to this directory. I didn't give those rights to IUSR and it compression works for me. Be default that directory seems to have IIS_WPG group with full control.
  • Next step is "Add new Web Service Extension for gzip.dll"
    • IIS Manager
    • Click on Web Service Extensions
    • Right click in empty space and choose "Add a new Web service extension.."
    • Call it HTTP Compression
    • Point it to c:¥windows¥system32¥inetsrv¥gzip.dll
    • Check the "Set extension status to Allowed" checkbox
  • Enable Direct Metabase Edit
    • IIS Manager, right click on Server node, choose properites
    • Set "enable direct metabase edit"
    • Below is excerpt from Scott's post

One of many large improvement with IIS 6 is that the metabase isn't in binary format anymore and can be edited directly using Notepad or any other tools that allows editing an XML file. Personally I prefer to enable Direct Metabase Edit so that I can edit it and the change takes affect immediately. If this isn't enabled, you will need to stop and start the web services for any changes to take affect. Of course, like editing the windows registry there is always the chance of something going wrong so be careful. Unlike the windows registry though, if you make a mistake and the metabase is saved and doesn't conform to the proper XML scheme, it won't take affect, so thanks to the IIS team it's quite difficult to completely mess up the metabase. To enable this, right-click on the server (top level) in the IIS snap-in. There is a single checkbox that needs to be checked. This part couldn't get easier.

  • Metabase edits
    • MAKE A BACKUP (see steps above)
    • 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.
    • Add your extensions (ASPX, JS, CSS, etc) 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="9 (from 0)
      • see Scott's post about the reasons why it should be 9 and not 10
    • Please see my next post about which extensions I added and some surprising results.
  • Last step is to IISRESET
  • Here are some statistics for the home page of www.reviewbasics.com. Images are not included in those numbers
    • Before compression:

351,210
text/javascript: 99,693
application/x-javascript: 143,287
text/xml: 649
application/x-shockwave-flash: 50,092
text/x-component: 1,832
text/html: 24,272
‾headers: 6,681
text/css: 24,704

·          

    • After compression:

223,629
text/javascript: 38,878
application/x-javascript: 108,231
text/xml: 649
application/x-shockwave-flash: 50,092
text/x-component: 3,664
text/html: 7,258
‾headers: 7,621
text/css: 7,236

This is ‾37% saving. I think that's pretty impressive for about 30 minutes of work. See my next post for some other interesting and impressive results

More