Apr 5, 2010

SharePoint Performance (IIS Http Compression and content expiration)

SharePoint Performance improvement by using IIS Http Compression and content expiration

Sites will be simply faster

Implemented http compression and content expiration, on IIS hosting the SharePoint sites and the page load time decreased to 3 seconds from around 6+ seconds.

To Improve SharePoint Site performance, one of the tweak you need to do is Http Compression at IIS Level

Benefits:

  • Effective bandwidth utilization, Conserve traffic and server resources
  • Faster transmission between Client/Server
  • Compress Static files, Compress Application response files (dynamic compression)

Performance Metrics

Before and after Implementing Http Compression on the Server Farm, following baseline metrics needs to be collected:

* CPU Usage under certain load or at certain times during the business hours
* Memory Usage under certain load or at certain times during the business hours
* Server Response time (Http Watch/ fiddler can be used)
         - This will help in making a decision, whether we can apply the dynamic compression or not.

Enabling HTTP compression,

1. In IIS Manager, double-click the local computer, right-click the Web Sites folder, and then click Properties.

2. Click the Service tab, and in the HTTP compression section, select the Compress application files check box to enable compression for dynamic files.

3. Select the Compress static files and Compress application files check box to enable compression for static/dynamic files.

4. In the Temporary directory box, click Browse to locate a directory. The directory must be on the local drive of an NTFS–formatted partition.

5. Under Maximum temporary directory size, click a folder size option.

6. Click Apply, and then click OK.


Static file is compressed, and it is cached in this temporary directory until it expires, or the content changes.

By default following files are compressed for Static compression: .txt, .htm, and .html

Dynamic files are compressed at runtime, means on demand when they are accessed by the end user. This means each time the file is being accessed the server CPU is under load.

By default following files are compressed for Dynamic compression: .exe, .dll, and .asp

Implementing compression (editing the Metabase.xml)

- Including certain file types

Static File Types > xml, rdf, css, js

Dynamic File Types > aspx, xsn, asmx, cgi

- level of compression

set to “9” should be changed to find the appropriate value based on the environment CPU utilization

On the WFE server look for Metabase.xml, located in the following directory: c:\windows\system32\inetsrv

Open the file and look for the following tags and replace it with the one given below:

<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"

HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"

HcCreateFlags="0"

HcDoDynamicCompression="TRUE"

HcDoOnDemandCompression="TRUE"

HcDoStaticCompression="TRUE"

HcDynamicCompressionLevel="9"

HcFileExtensions="htm

html

xml

css

txt

rdf

js"

HcOnDemandCompLevel="9"

HcPriority="1"

HcScriptFileExtensions="asp

cgi

exe

dll

aspx

asmx

xsn"

>

</IIsCompressionScheme>

<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"

HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"

HcCreateFlags="1"

HcDoDynamicCompression="TRUE"

HcDoOnDemandCompression="TRUE"

HcDoStaticCompression="TRUE"

HcDynamicCompressionLevel="9"

HcFileExtensions="htm

html

xml

css

txt

rdf

js"

HcOnDemandCompLevel="9"

HcPriority="1"

HcScriptFileExtensions="asp

cgi

exe

dll

aspx

asmx

xsn"

>

</IIsCompressionScheme>

<IIsCompressionSchemes Location ="/LM/W3SVC/Filters/Compression/Parameters"

HcCacheControlHeader="max-age=86400"

HcCompressionBufferSize="8192"

HcCompressionDirectory="%windir%\IIS Temporary Compressed Files"

HcDoDiskSpaceLimiting="FALSE"

HcDoDynamicCompression="TRUE"

HcDoOnDemandCompression="TRUE"

HcDoStaticCompression="TRUE"

HcExpiresHeader="Wed, 01 Jan 1997 12:00:00 GMT"

HcFilesDeletedPerDiskFree="256"

HcIoBufferSize="8192"

HcMaxDiskSpaceUsage="99614720"

HcMaxQueueLength="1000"

HcMinFileSizeForComp="1"

HcNoCompressionForHttp10="FALSE"

HcNoCompressionForProxies="FALSE"

HcNoCompressionForRange="FALSE"

HcSendCacheHeaders="FALSE"

>

</IIsCompressionSchemes>


* Ignore br tag

NOTE:

-- Cannot edit or save the IIS metabase.xml file
To edit the IIS metabase file without stopping IIS, you must enable Edit-While-Running.

Procedure:

- To enable metabase edit-while-running using IIS Manager

- In IIS Manager, right-click the local computer, and then click Properties.

- Select the Enable Direct Metabase Edit check box.

Instead of editing “metabase.xml”, we could use the following command but it doesn’t seem to work quite well.

cscript.exe adsutil.vbs …


Enabling Content Expiration for Client (Browser) Caching

In the IIS Manager, right click on the website and goto properties as shown below

One you have the settings as shown above, i.e.

- Enable content expiration checked mark

- Expire after should be set to around 30 days or based on application

- Under Custom Http Headers should have the following via edit

- An example of a Cache-Control server-response header is

o Cache-Control: max-age=3600

o Cache-Control: max-age=3600, must-revalidate

The must-revalidate attribute speeds up the caching process by rendering the repeated download of entire pages or objects unnecessary. If the data's freshness is unknown, the browser can contact the server to determine whether an update has occurred. If no changes to the object have occurred, the browser uses the cached copy.

§ Time is in seconds

Restart the IIS before testing the performance for your sites and comparing the baseline metrics.



NOTE You should consider testing the impact of compression levels and monitor the CPU utilization and potential impact to your Web servers. Generally, a compression level between 7 and 9 provides optimum performance


Testing:

Open the site using IE and enable the recording in the httpWatch, you should see something like following when navigating to home page (default.aspx):

Also look at the content in the next screen shot below:



Validate content expiration for pages other than some like default.aspx as shown below:

NOTE: At last but not the least, The above procedure needs to be implemented on all Web Front End (WFE) servers in the SharePoint Farm

For other performance tips follow SharePoint Performance Tuning

No comments:

Pages