Fine tuning Dynamic Worker-Process Page-out on IIS 8.5

With the release of Windows 2012 R2, IIS now offers the option of configuring sites to suspend after they have been idle for a while (in addition to the option of terminate, which existed since IIS 7). We have discussed this feature in the past both in this blog, and during our TechEd North America presentation. This time, though, we are going to take a look into fine-tuning the settings for optimal performance.

The main purpose of both the WP Page-out and WP Termination features is to conserve memory utilization on the server, since a site can consume a lot of memory even if it’s just sitting there, listening. Depending on the technology used on the site (static content vs ASP.NET vs other frameworks), the memory used can be anywhere from about 10 MB to hundreds of MBs, and this means that if your server is configured with many sites, figuring out the most effective settings for your sites can dramatically improve performance of both active and suspended sites.

Before we go into specifics, we must keep in mind that if there are no memory constraints, then it’s probably best to simply set the sites to never suspend or terminate. After all, there’s little value (*) in terminating a worker process if it’s the only one on the machine. Another factor to consider is that if the site does use a lot of memory, then the suspension process itself takes a toll, because the computer has to write the data used by the Worker Process to disk. If the WP is using a large chunk of memory, then suspending it might be more “expensive” than the cost of having to wait for it to spin-up (if it were terminated).

* In case the site runs unstable code, such as code with a memory leak, or otherwise unstable, setting the site to terminate on idle can be a quick-and-dirty alternative to fixing the code bug. This isn’t something we would encourage, but in a crunch, it may be better to use this feature as a clean-up mechanism while a more permanent solution is in the works.

To make the best of the site suspension feature, you need to review your sites, and decide which should be suspended, which should be terminated, and which should be active indefinitely. For each action and each site, you need to figure out the ideal time-out period.

Ideally, the sites that you will configure for suspension or termination are those that have visitors every day, but not enough to warrant keeping it active all the time. These are usually sites with around 20 unique visitors a day or less. You can analyze the traffic patterns using the site’s log files and calculate the average daily traffic.

Keep in mind that once a specific user connects to the site, they will typically stay on it for at least a while, making additional requests, and so just counting daily requests may not accurately reflect the real traffic patterns. To get a more accurate reading, you can also use a tool like Excel to calculate the average time between requests. For example:

 

Request URL

Request Time

Delta

1

/SourceSilverLight/Geosource.web/grosource.html

10:01

 

2

/SourceSilverLight/Geosource.web/sliverlight.js

10:10

0:09

3

/SourceSilverLight/Geosource.web/clientbin/geo/1.aspx

10:11

0:01

4

/lClientAccessPolicy.xml

10:12

0:01

5

/ SourceSilverLight/GeosourcewebService/Service.asmx

10:23

0:11

6

/ SourceSilverLight/Geosource.web/GeoSearchServer….

11:50

1:27

7

/rest/Services/CachedServices/Silverlight_load_la…

12:50

1:00

8

/rest/Services/CachedServices/Silverlight_basemap….

12:51

0:01

9

/rest/Services/DynamicService/ Silverlight_basemap….

12:59

0:08

10

/rest/Services/CachedServices/Ortho_2004_cache.as...

13:40

0:41

11

/rest/Services/CachedServices/Ortho_2005_cache.js

13:40

0:00

12

/rest/Services/CachedServices/OrthoBaseEngine.aspx

13:41

0:01

 

The hard part, though, is figuring out what setting to apply to make sense. In our case, the site gets a bunch of requests from users, and the table above shows that a total of 4 unique sessions occurred in a period of 4 hours. With the default settings for site suspension, the site would be terminated after the default timeout of 20 minutes, which means each of these users would experience the site spin-up cycle. This makes it an ideal candidate for site suspension, because for most of the time, the site is idle, and so suspending it would conserve resources, and allow the users to reach the site almost instantly.

A final, and very important note about this is that disk performance is crucial for this feature. Because the suspension and wake-up process involve writing and reading large amount of data to the hard drive, we strongly recommend using a fast disk for this. Solid State Drives (SSDs) are ideal and highly recommended for this, and you should make sure that the Windows page file is stored on it (if the operating system itself is not installed on the SSD, configure the operating system to move the Page file to it).

Whether you use an SSD or not, we also recommend fixing the size of the page file to accommodate writing the page-out data to it without file-resizing. Page-file resizing might happen when the operating system needs to store data in the page file, because by default, Windows is configured to automatically adjust its size based on need. By setting the size to a fixed one, you can prevent resizing and improve performance a lot.

To configure a pre-fixed page file size, you need to calculate its ideal size, which depends on how many sites you will be suspending, and how much memory they consume. If the average is 200 MB for an active worker process (W3WP) and you have 500 sites on the servers that will be suspending, then the page file should be at least (200 * 500) MB over the base size of the page file (so base + 100 GB in our example). Note that when sites are suspended, they will consume approximately 6 MB each, so in our case, memory usage if all sites are suspended would be around 3 GB. In reality, though, you’re probably never going to have them ALL suspended at the same time, so your mileage will vary.

 Blog post written by Ahmed ElSayed and Erez Benari

 

No Comments