/ Performance

Spice up Sitecore Performance with IIS

Let's walk through quick and easy ways to improve Sitecore Performance at the IIS level. The tips and tricks are mostly used when we setup a new environment.

The changes mentioned will need IIS reset to take effect use with caution.

Compression
Compression helps in reducing the payload transferred to the client browser. Reduce in size, increases faster transfer and helps load the website faster.

Select the site and click the compression.
sitecore_performance_iis_brotli_1

Enable both the compressions available.
sitecore_performance_iis_brotli_2

When you try to check the compression, it might show Dynamic compression as checked and grayed out. In that case the feature is not installed.

The Compression role should be installed at the server role as follows.
sitecore_performance_iis_brotli_0

Compression Types
IIS supports multiple types of compression. The widely used one for a long time is Gzip. IIS has set the default compression scheme provider as Gzip, supports both Gzip and Deflate compression. It is registered as the Gzip scheme in applicationHost.config.

Brotli
Brotli is a new standard that provides better compression than gzip it is supported by all major browsers. The compression algorithm is developed by Google and widely used.

Brotli performance when compared to gzip, might not look that big but when browsing on a mobile phone everything counts.

  • 14% smaller for JavaScript
  • 21% smaller for HTML
  • 17% smaller for CSS
    Ref Akamai

Can I use Brotli?

sitecore_performance_iis_brotli_5

Ref: https://docs.microsoft.com/en-us/iis/extensions/iis-compression/iis-compression-overview

Script Install
Automated install script for easy install on multiple servers. Save the installer and this script in the same folder and execute as administrator. The powershell script will install and configure Brotli compression prioritizing over Gzip.

Manual Install
Backup the application host config from the following location before any updates.

%windir%\System32\inetsrv\config\applicationHost.config

Download the Microsoft IIS Compression release and install the appropriate package.
Microsoft IIS Compression (x86) here.

Microsoft IIS Compression (x64) here.

By default, the Gzip is listed as the first supported compression in the request header. Looking at this the server will use the Gzip scheme.
sitecore_performance_iis_brotli_3

We will use the hack to overcome and priorotize Brotli over Gzip if the browser supports. Create the following rewrite rule at the Site level
sitecore_performance_iis_brotli_6

Pattern: .*
Conditions: {HTTP_ACCEPT_ENCODING} \bbr(?!;q=0)\b
Server variable: HTTP_ACCEPT_ENCODING br

Ref: Server fault answer

Results
The content encoding in response header will be br when it uses the Brotli compression.
sitecore_performance_iis_brotli_4

Time to Live (TTL)
By default TTL will not be enabled and all the content will be downloaded every time from the server, this will affect the performance. Enable default TTL at the IIS level between 7-30 days or more.
sitecore_performance_iis_ttl_0

Media library Item TTL is set at Sitecore level, default value is 7 days that can be increased by using the following patch.

App Pool Timeout
Ensure the production Idle Time-out is set to 0.
sitecore_performance_iis_apppool_0

App Pool Recycling
Disable the default recycling on regular intervals.
sitecore_performance_iis_apppool_1

HTTP/2
HTTP/2 support is available in Windows 10 and Windows Server 2016. HTTP/2 is a major upgrade after nearly two decades of HTTP/1.1 use and reduces the impact of latency and connection load on web servers. In HTTP/2, a persistent connection can be used to service multiple simultaneous requests with several additional features that improve the efficiency of HTTP over the network.
https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/http2-on-iis

If you are using a load balancer this has to be enabled on that network device.

By default http/1.1 can do only 6-8 simultaneous connection depending on the browser.
The following image you can see the waterfall in the last column multiple connection at the same time due to h2 protocol.
sitecore_performance_iis_http2

Photo by Christian Englmeier on Unsplash