IIS 6.0 Compression
Introduction
Overview – What Problem Does IIS Compression Solve?
Total response time is composed of 3 major components. This can be expressed as a formula:
User response time = server processing time + network transmission time + client rendering time
The network transmission time can be a major component for remote users accessing SharePoint over WAN links. Reducing the number of bytes transmitted can reduce the network time. IIS Compression can accomplish this reduction in the number of bytes transmitted.
IIS compression is highly configurable. Compression can be scoped to:
-
Static, dynamic, or both static and dynamic content.
-
Entire web sites, specific directories, or even individual files.
-
Specific file types based upon file extension.
The compression level is a number between 0 and 10, where 10 is the greatest compression. More CPU resources are required for higher compression numbers.
When SharePoint installed, IIS is configured to compress both static and dynamic files.
By default static compression is on the file types: HTM, HTML, and TXT at level 10.
By default static compression is on the file types: ASP and EXE at level 0.
Static verses Dynamic Compression
Compressed static responses are cached to disk. Once the compressed page is cached, there is no further CPU overhead until the cache expires. Static compression can have dramatic effects; for example: core.js is 257 KB on disk, but IIS static compression reduces it to 54 KB.
Dynamic compression requires trial-and-error testing to find the optimal settings. Dynamic compression can affect CPU resources because IIS does not cache compressed dynamic output. If compression is enabled for dynamic responses and IIS receives a request for a file that contains dynamic content, the response that IIS sends is compressed every time it is requested.
Because dynamic compression consumes considerable CPU time and memory resources, use it only on servers that have underutilized CPUs. If web site generates a large volume of dynamic content, consider whether the additional processing cost of HTTP compression can be reasonably afforded. If the % Processor Time counter is already 80 percent or higher, enabling HTTP compression is not recommended.
To evaluate how much of your processor is typically being used, follow these steps:
-
Establish a baseline for your processor usage by using System Monitor to log the following counters over several days. If you use Performance Logs and Alerts, you can log the data to a database and then query the data, examining the results in detail.
- Processor\% Processor Time. This counter has a total instance and a separate instance for each processor in the system. If your server has more than one processor, you need to watch the individual processors as well as the total to discover any imbalance in the workload.
- Network Interface\Bytes Sent/sec. Counters for the Network Interface performance object display the rate at which bytes are transmitted over a TCP/IP connection by monitoring the counters on the network adapter.
- Enable compression, and continue to log the values for these counters for an extended period — preferably for several days — so you have a good basis for comparison. Collect a broad sample to determine how compression affects various aspects of performance. Conduct the following tests:
-
Try variations of compression settings.
- Enable static compression only, dynamic compressions only, and both.
- Change the list of files that you use for compression testing for both static and dynamic content.
- Vary the compression level.
Use the performance logs to determine the sweet spot at which Network Interface Bytes is reduced the most while % Processor Time remains below 80%.
Global, Web Site, Directory, File Scoping
Both static and dynamic compression can be configured at multiple scopes by scripting or by using the Metabase GUI tool.
The script C:\Inetpub\AdminScripts\adsutil.vbs is the recommended approach for configuration. This allows automated scripts to be applied to all web servers.
Gzip and Deflate
There are 2 types of compression: gzip and deflate. Gzip is actually a superset of deflate. Both should be configured the same (same types of files and same level of compression), so browsers using either compression method with get similar results.
Recommended Initial Configuration
These are the recommended starting values for gzip and deflate compression. These values can be adjusted based upon performance counter captures, to optimize the network bytes transmitted while keeping the CPU load within reasonable bounds.
HcDoStaticCompression : (BOOLEAN) True HcDoDynamicCompression : (BOOLEAN) True HcOnDemandCompLevel : (INTEGER) 10 HcDynamicCompressionLevel : (INTEGER) 0 HcScriptFileExtensions : (LIST) (6 Items) "asp" "exe" "axd" "ascx" "asmx" "aspx" HcFileExtensions : (LIST) (5Items) "htm" "html" "txt" "css" "js"
Configuring IIS 6.0
Open a command prompt.
Change directory to C:\Inetpub\AdminScripts
Directory of C:\Inetpub\AdminScripts 04/03/2007 05:46 PM <DIR> . 04/03/2007 05:46 PM <DIR> .. 11/13/2006 10:08 AM 85,813 adsutil.vbs 02/21/2003 08:48 PM 6,064 synciwam.vb 2 File(s) 91,877 bytes 2 Dir(s) 43,512,107,008 bytes free C:\Inetpub\AdminScripts>
Global Configuration
Capture the current settings for a historical record.
>cscript adsutil.vbs enum W3Svc/Filters/Compression/Parameters Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. KeyType : (STRING) "IIsCompressionSchemes" HcCompressionDirectory : (EXPANDSZ) "%windir%\IIS Temporary Compressed Files" HcCacheControlHeader : (STRING) "max-age=86400" HcExpiresHeader : (STRING) "Wed, 01 Jan 1997 12:00:00 GMT" HcDoDynamicCompression : (BOOLEAN) False HcDoStaticCompression : (BOOLEAN) True HcDoOnDemandCompression : (BOOLEAN) True HcDoDiskSpaceLimiting : (BOOLEAN) True HcNoCompressionForHttp10 : (BOOLEAN) True HcNoCompressionForProxies : (BOOLEAN) True HcNoCompressionForRange : (BOOLEAN) False HcSendCacheHeaders : (BOOLEAN) False HcMaxDiskSpaceUsage : (INTEGER) 99614720 HcIoBufferSize : (INTEGER) 8192 HcCompressionBufferSize : (INTEGER) 8192 HcMaxQueueLength : (INTEGER) 1000 HcFilesDeletedPerDiskFree : (INTEGER) 256 HcMinFileSizeForComp : (INTEGER) 1 >cscript adsutil.vbs enum W3Svc/Filters/Compression/DEFLATE Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. KeyType : (STRING) "IIsCompressionScheme" HcDoDynamicCompression : (BOOLEAN) True HcDoStaticCompression : (BOOLEAN) True HcDoOnDemandCompression : (BOOLEAN) True HcCompressionDll : (EXPANDSZ) "%windir%\system32\inetsrv\gzip.dll" HcFileExtensions : (LIST) (3 Items) "htm" "html" "txt" HcScriptFileExtensions : (LIST) (2 Items) "asp" "exe" HcPriority : (INTEGER) 1 HcDynamicCompressionLevel : (INTEGER) 0 HcOnDemandCompLevel : (INTEGER) 10 HcCreateFlags : (INTEGER) 0 >cscript adsutil.vbs enum W3Svc/Filters/Compression/GZIP Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. KeyType : (STRING) "IIsCompressionScheme" HcDoDynamicCompression : (BOOLEAN) True HcDoStaticCompression : (BOOLEAN) True HcDoOnDemandCompression : (BOOLEAN) True HcCompressionDll : (EXPANDSZ) "%windir%\system32\inetsrv\gzip.dll" HcFileExtensions : (LIST) (6 Items) "htm" "html" "txt" HcScriptFileExtensions : (LIST) (3 Items) "asp" "exe" HcPriority : (INTEGER) 1 HcDynamicCompressionLevel : (INTEGER) 0 HcOnDemandCompLevel : (INTEGER) 10 HcCreateFlags : (INTEGER) 1
Enable a setting; for example, turn on global static compression if it is currently off:
>cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcDoStaticCompression : (BOOLEAN) True
Add CSS and JS file types to the static compressed file types. CSS (Cascading Stylesheets) and JS (JavaScript) will provide the most performance gains with SharePoint
>cscript adsutil.vbs SET W3SVC/Filters/Compression/Deflate/HcFileExtensions "htm" "html" "txt" "css" "js" Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcFileExtensions : (LIST) "htm" "html" "txt" "css" "js" >cscript adsutil.vbs get W3SVC/Filters/Compression/Deflate/HcFileExtensions Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcFileExtensions : (LIST) (1 Items) "htm "html" "txt" "css" "js" >cscript adsutil.vbs SET W3SVC/Filters/Compression/gzip/HcFileExtensions "htm" "html" "txt" "css" "js" Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcFileExtensions : (LIST) "htm" "html" "txt" "css" "js" >cscript adsutil.vbs GET W3SVC/Filters/Compression/gzip/HcFileExtensions Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcFileExtensions : (LIST) (1 Items) "htm" "html" "txt" "css" "js"
Add AXD, ASMX, & ASPX to dynamic file list. Tip: Don't compress JPG/JPEG images (already compressed).
>cscript adsutil.vbs SET W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "exe" "axd" "aspx" Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcScriptFileExtensions : (LIST) "asp" "exe" "axd" "aspx" "asmx" >cscript adsutil.vbs GET W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcScriptFileExtensions : (LIST) (5 Items) "asp" "exe" "axd" "asmx" "aspx" >cscript adsutil.vbs SET W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "exe" "axd" "apx" Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcScriptFileExtensions : (LIST) "asp" "exe" "axd" "aspx" "asmx" >cscript adsutil.vbs GET W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcScriptFileExtensions : (LIST) (4 Items) "asp" "exe" "axd" "asmx" "aspx"
Consider testing the impact of varying compression levels in a laboratory environment closely monitoring CPU utilization and potential impact to the Web servers. Typically a compression level between 7 and 9 provides optimum performance vs. CPU load in most circumstances. Tip: Start with dynamic compression level set to 4, and then try increasing to see the CPU impact.
>cscript adsutil.vbs SET W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel 4 Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcDynamicCompressionLevel : (INTEGER) 4 >cscript adsutil.vbs GET W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcDynamicCompressionLevel : (INTEGER) 4 >cscript adsutil.vbs SET W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel 4 Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcDynamicCompressionLevel : (INTEGER) 4 >cscript adsutil.vbs GET W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. HcDynamicCompressionLevel : (INTEGER) 4
Web Site Scope Configuration
In some cases you may wish to enable or disable compression at only the site or site element level as opposed to global level. Use the path to the web site in the adsutil command line. You can determine the site path using the IIS Metabase Explorer application available in the IIS 6.0 Resource Kit, or by enumerating sites using the adsutil.vbs script.
>cscript adsutil.vbs enum w3svc
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
KeyType : (STRING) "IIsWebService"
MaxConnections : (INTEGER) 4294967295
AnonymousUserName : (STRING) "IUSR_EPGOPSR2BASE"
AnonymousUserPass : (STRING) "**********"
ConnectionTimeout : (INTEGER) 120
AllowKeepAlive : (BOOLEAN) True
DefaultDoc : (STRING) "Default.htm,Default.asp,index.htm"
HttpCustomHeaders : (LIST) (1 Items)
"X-Powered-By: ASP.NET"
(many lines removed here)
[/w3svc/1513483211]
[/w3svc/1669737538]
[/w3svc/1720207907]
[/w3svc/2004785039]
[/w3svc/809964160]
[/w3svc/941433650]
[/w3svc/AppPools]
[/w3svc/Filters]
[/w3svc/Info]
You can match the w3svc web site numbers to the web site name using the IIS Manager MMC. In the following picture we see the collaboration web site is web site ID 809964160.
If we assume the collaboration web site is only accessed by users on the local LAN where network bandwidth is not an issue, we can disable dynamic compress for just this web site by using the web site metabase path (w3svc/809964160/root/) to set the DoDynamicCompression parameter.
>cscript adsutil.vbs SET w3svc/809964160/root/DoDynamicCompression false Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. DoDynamicCompression : (BOOLEAN) False
Restart IIS
After completing the configuration changes, always restart IIS. At a command prompt, either enter
IISReset
Or
NET STOP W3SVC NET START W3SVC
Example Improvement with Compression
With static compression set to 10, and dynamic compression set to 4, Fiddler captured these statistics for a publishing site home page. The round trip cost and elapsed time values are estimates based upon typical network latency.
Request Count: 43 Bytes Sent: 24,716 Bytes Received: 218,719 ACTUAL PERFORMANCE -------------- Requests started at: 08:37:02:5221 Responses completed at: 08:37:05:0157 Total Sequence time: 00:00:02.4935856 RESPONSE CODES -------------- HTTP/401: 8 HTTP/200: 35 RESPONSE BYTES (by Content-Type) -------------- image/gif: 30,479 text/css: 17,003 ~headers: 18,432 image/jpeg: 13,634 text/html: 28,335 application/x-javascript: 110,836 ESTIMATED WORLDWIDE PERFORMANCE -------------- The following are VERY rough estimates of download times when hitting servers based in WA, USA. US West Coast (Modem - 6KB/sec) --------------- Round trip cost: 4.30s Elapsed Time: 44.30s Japan / Northern Europe (Modem) --------------- Round trip cost: 6.45s Elapsed Time: 46.45s China (Modem) --------------- Round trip cost: 19.35s Elapsed Time: 59.35s US West Coast (DSL - 30KB/sec) --------------- Round trip cost: 4.30s Elapsed Time: 12.30s Japan / Northern Europe (DSL) --------------- Round trip cost: 6.45s Elapsed Time: 14.45s China (DSL) --------------- Round trip cost: 19.35s Elapsed Time: 27.35s
These results are for the same page with static and dynamic compression disabled.
Request Count: 39 Bytes Sent: 21,626 Bytes Received: 772,669 ACTUAL PERFORMANCE -------------- Requests started at: 08:41:59:8797 Responses completed at: 08:42:25:8069 Total Sequence time: 00:00:25.9272816 RESPONSE CODES -------------- HTTP/401: 2 HTTP/200: 37 RESPONSE BYTES (by Content-Type) -------------- image/gif: 30,565 text/css: 103,482 ~headers: 15,093 image/jpeg: 13,634 text/html: 72,976 application/x-javascript: 536,919 ESTIMATED WORLDWIDE PERFORMANCE -------------- The following are VERY rough estimates of download times when hitting servers based in WA, USA. US West Coast (Modem - 6KB/sec) --------------- Round trip cost: 3.90s Elapsed Time: 135.90s Japan / Northern Europe (Modem) --------------- Round trip cost: 5.85s Elapsed Time: 137.85s China (Modem) --------------- Round trip cost: 17.55s Elapsed Time: 149.55s US West Coast (DSL - 30KB/sec) --------------- Round trip cost: 3.90s Elapsed Time: 29.90s Japan / Northern Europe (DSL) --------------- Round trip cost: 5.85s Elapsed Time: 31.85s China (DSL) --------------- Round trip cost: 17.55s Elapsed Time: 43.55s
Note the following differences:
|
Description
|
With Compression
|
Without Compression
|
|
Bytes Received:
|
218,719
|
772,669
|
|
RESPONSE BYTES (by Content-Type)
|
image/gif: 30,479
text/css: 17,003
~headers: 18,432
image/jpeg: 13,634
text/html: 28,335
application/x-javascript: 110,836
|
image/gif: 30,565
text/css: 103,482
~headers: 15,093
image/jpeg: 13,634
text/html: 72,976
application/x-javascript: 536,919
|
|
Japan / Northern Europe (DSL)
|
Round trip cost: 6.45s
Elapsed Time: 14.45s
|
Round trip cost: 5.85s
Elapsed Time: 31.85s
|
|
China (DSL)
|
Round trip cost: 19.35s
Elapsed Time: 27.35s
|
Round trip cost: 17.55s
Elapsed Time: 43.55s
|
References
IIS 6.0 Resource Guide: |
http://www.microsoft.com/downloads/details.aspx?FamilyID=80a1b6e6-829e-49b7-8c02-333d9c148e69&DisplayLang=en
Using Granular Compression in IIS 6.0 Webcast: http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032270805&EventCategory=3&culture=en-US&CountryCode=US
Metabase Property Reference (IIS 6.0)
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/c63788cc-70b4-4a44-a9a3-329fa8fb3afb.mspx?mfr=true
Using HTTP Compression for Faster Downloads (IIS 6.0)
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/25d2170b-09c0-45fd-8da4-898cf9a7d568.mspx?mfr=true
HTTP Compression, Internet Information Services 6.0, and SharePoint Products and Technologies
http://blogs.technet.com/wbaer/archive/2008/01/30/http-compression-internet-information-services-6-0-and-sharepoint-products-and-technologies.aspx