Internet Information Services
(IIS) that can substantially impact your overall SharePoint 2010 performance—particularly
for those with slow network connections. IIS supports compression of thecontent before it’s returned to the client. This process provides efficient use
of bandwidth resources at the expense of some CPU time. The settings in IIS7—required by SharePoint 2010—allow you to not only control the amount of
compression but you can have IIS automatically disable compression when the CPU
utilization of the server is too high.
Compression is enabled based on
two dimensions.
The first dimension is the MIME type of the file that’s
being returned. This allows you to have different settings for text documents,
as compared with .jpg, .gif, .cab, and .zip documents from text, HTML, and XML
documents. Attempting to compress .jpg, .gif, .cab, and .zip will not yield
much (if any) improvement in size, because they are already compressed. On the
other hand, text including HTML and XML is generally highly compressible, so
even a small amount of effort to try to compress them can sometimes yield
impressive results.
The second dimension is whether
the output is a static file or whether the content was generated dynamically,
which is the case for much of SharePoint. Static compression is less expensive,
and therefore can be done more aggressively. The files are compressed once and
then stored in their compressed state to be served the next time the file is
requested. This makes the CPU load for compressing static files trivial for
most applications. Dynamic pages, however, need to be compressed on every
single output and can therefore put a larger load on the CPUs. As a result, a
setting more in the neighborhood of four is appropriate for dynamic content.
You can also instruct IIS to cache
dynamic content after compression if you believe that this will help improve
performance. If you’re using page output caching, this may be a useful way to
minimize the impact of compression on CPU utilization. This does slow down
initial response time, so it’s advisable only when you expect the cache to be
reused.
You should review IIS 7 compression and performance impact from various
compression levels and to see how much adjusting is needed to finely tune a
Windows web server. You should understand the IIS 7 compression default values
before you change them.
While you could set up the IIS compression from IIS UI, it would
be convenient to automate the configuration through script. Joel Plaut has a good summary to set up compression
and I have incorporate some suggestion from Microsoft best practice. Here is
the modified script named SetIISCompression.cmd and you could adjust it for your environment.
REM appcmd
command is located in C:\Windows\System32\Inetsrv
C:
cd C:\Windows\System32\Inetsrvappcmd
list config -section:httpcompression
REM Enable
Static and Dynamic compressions
appcmd set config /section:urlCompression
/doStaticCompression:True
appcmd set config /section:urlCompression
/doDynamicCompression:True
REM Set
static compression to 9 and dynamic compression to 4 as Microsoft recommended
appcmd
set
config
-section:httpCompression -[name='gzip'].staticCompressionLevel:9 -[name='gzip'].dynamicCompressionLevel:4
REM Disable static
compression when CPU 80% - default is 100%
appCmd
set
config -section:httpCompression /staticCompressionDisableCpuUsage:80
appCmd
set
config -section:httpCompression /
staticCompression
Enable
CpuUsage
:50
REM Disable dynamic
compression when CPU 80% - default is 90%
appCmd
set
config -section:httpCompression
/dynamicCompressionDisableCpuUsage:80
appCmd
set
config -section:httpCompression /dynamicCompressionEnableCpuUsage:50
REM Set
minimal file size for compression to 512 KB – default is 256 KB
appCmd
set
config -section:httpCompression
/MinFileSizeForComp:512
REM Set number
of megabytes of disk space that compressed files can occupy in the compression
directory – default is 100 MB
appCmd
set
config -section:httpCompression /maxDiskSpaceUsage:200
appcmd
list config -section:httpcompression
Can you share some tips specifically to sharepoint like when to enable Static compression, can static JS/CS or other file files residing in SharePoint Content DB take advantage of static compression?
ReplyDeleteThis comment has been removed by the author.
ReplyDeletePretty article! I found some useful information in your blog,sharepoint developer training
ReplyDeleteit was awesome to read, thanks for sharing this great content to my vision, keep sharing..