Optimising Windows Server 2008 R2

Optimising Windows Server 2008 R2 for EC2 micro instance

AWS EC2 micro instances are designed to be suitable for running small web sites. They can provide relatively good performance for short time periods but sustained CPU use will result in the instance being throttled. In order to get best performance running Windows Server on a micro instance we want to remove any unnecessary tasks that will result in sustained CPU use.

Here is a non exhaustive list of the configuration changes that can be made

Disable Windows Update

When Windows Update runs to check for updates it can take a significant length of time. This will be long enough to trigger the AWS CPU throttling. Fortunately Windows Updates are generally released on a schedule usually referred to as ‘Patch Tuesday’. The Microsoft Security TechCenter list a number of ways you can receive notification about impending releases.

Stop SQL Server from auto unloading database

By default SQL Server will unload a database if it has not been used recently. This may make sense on a server used for multiple applications, but on a micro instance we don’t want to incur the penalty of reloading the database.

Stop IIS from shutting down AppPool

IIS will shutdown a worker process in an AppPool if it has been idle for a length of time. The default idle time is 20 minutes

In IIS Manager open the Advanced Settings of the Application Pool, the Idle Time (minutes) setting is in the Process Model section

Extend AppPool restart

By default the AppPool is set to recycle after 29 hours. AppPool recycling can take long enough to trigger AWS CPU throttling. Given that your site is getting few enough hits to run on a micro instance, you should be able significantly increase the recycling timeout.

Use IIS app warmup

Starting the AppPool and your application may take long enough to trigger CPU throttling slowing the response to the user. You can configure IIS to show a static splash page whilst your application is starting up.

Details can be be found here: IIS 8.0 Application Initialization and here: Application Initialization Module for IIS 7.5

robots.txt

The majority of your traffic is likely to come from web crawlers. This will be from search engine bots — which you want, and from a variety of unknown sources. Some of these will crawl your site at a reasonable rate, some will hammer it. If this becomes really problematic you can set rules in IIS to block certain IP address, however most of the problems can be resolved by adding the Crawl-delay directive to your Robot.txt file

Crawl-delay: 10