IIS has been around for more than 17 years, ever since its first release in Windows NT 3.51. It started out as a basic HTTP server and has evolved to a fully configurable, highly secure and high-performing webserver. You can pretty much host anything on IIS; right from media streaming to hosting scalable web applications.
With the release of Windows Server 2012 R2 and Windows 8.1, a new version of IIS – version 8.5 has been launched which contains several new and exciting features. Some of the new features are listed below –
- Dynamic Website Activation in IIS 8.5
- Idle worker process Page-Out in IIS 8.5
- Enhanced Logging for IIS 8.5
- Logging to Event Tracing for Windows in IIS 8.5
In this article, we will discuss some of these new features and also see them in action. We will compare these new features with IIS 8.0 which was released with Windows Server 2012, almost a year before R2 was released. Although I have explored these new features in Windows 8.1, you can easily replicate them in Windows Server 2012 R2.
This article is published from the DotNetCurry .NET Magazine – A Free High Quality Digital Magazine for .NET professionals published once every two months. Subscribe to this eMagazine for Free and get access to hundreds of free tutorials from experts
Dynamic Website Activation in IIS 8.5
While using IIS 8.0 in Windows Server 2012, if you are hosting a number of websites, IIS will activate all the websites which are configured in it, during a system boot-up. The good thing about automatic activation of all the configured sites is that they are ready to respond whenever the first request arrives. But there is also a downside to automatic activation. The first being, it takes a bit of time to load the IIS configuration file and activate all the sites. This is because the Windows Process Activation Service (WAS) has to load the configuration of all websites hosted on IIS. Second being the sites which are activated, consume a lot of memory. Many of these sites may be requested instantly but what about the sites which are not at all called or are called after a certain time period. The activation time and memory consumption is unnecessary in that situation.
Let’s observe IIS 8.0 activation. I have preconfigured 12 sites on IIS 8.0. Now I am opening PowerShell and writing below command to check the service state running under IIS 8.0 –
After running this command, you will see all the 12 sites are queued up as shown below –
When you have a couple of hundred of websites hosted on your server, it makes sense to activate the website when the first request is made for it. By addressing this problem, IIS 8.5 has now introduced a new feature called as the “Dynamic Website Activation”.
With Dynamic Website Activation, IIS 8.5 does not activate all sites during boot-up time. Rather IIS will activate the site when the first request is received by it. This activation may take some time initially, but after that all other subsequent requests will respond as expected. This will reduce the consumption of memory and unused resources which would unnecessarily occur during boot-up time, especially for those websites that are accessed rarely or not accessed at all.
IIS 8.5 now lets you set the threshold while configuring dynamic website activation. Let’s see how this feature can be utilized.
Open IIS Manager. Choose Server in a Connection Pane located on the left hand side and from the Management Section in the right side, choose Configuration Editor as shown here:
Once you open the Configuration Editor, from the section dropdown list choose system.applicationHost and then the webLimits section as shown here:
This brings up the dynamic registration threshold which is by default set to 100 as shown below –
You can now change the value as per your requirement. When the threshold is set to 100 [this is default value] and if the number of sites are less than 100, IIS will by default activate all the sites. However in cases where you have 100 or more than 100 sites, IIS will activate each site when the first request is received for the site. When you change the threshold value, make sure you restart IIS.
Now let’s test the service state again now for IIS 8.5. I have preconfigured my IIS with the same 12 sites which I had configured in IIS 8.0 a short while ago. I have set the dynamic registration threshold to 5 just for testing purpose. I am running NetSh command in PowerShell –
The output is as shown below –
I have a total of 5 sites activated currently. If I start one more, my count will go to 6. This way IIS is only activating the site when the first request comes in, thereby reducing the consumption of resources.
Idle worker process Page-Out in IIS 8.5
In IIS 8.0, the administrator can set the timeout for the worker process when it is in an idle state. In one way, it is a good option as the process gets terminated due to inactivity, thereby freeing the resources associated with it. On the other hand, it is a disadvantage as well. When the site is accessed the next time, the worker process takes time to complete its startup process, which keeps the user waiting. Let’s check the timeout option of Application Pool in IIS 8.0 as shown below –
Now let’s compare the same with IIS 8.5 Idle worker process timeout setting as shown here –
As you might have observed, we now have an Idle Time-out Action setting which we can set to either Suspend or Terminate. The default value is Terminate. You can change that to Suspend.
Just for comparison, I am changing the Idle Time-out (minutes) to 1 minute and performing the testing in IIS 8.0. Below are the observations –
After one minute, you will observe the worker process has been terminated. When you try accessing the site once again, it will take some time to start up. Now let’s observe the same demonstration under IIS 8.5. I have set the Idle time-out action to “Suspend”. Let’s run the site and see the difference –
After starting the website, following is the observation –
When the time-out occurs, you will see the same worker process now consuming less memory:
The observation is that the worker process has not been terminated. It is still alive but has been paged out to the disk. As it gets paged out to disk, it ends up in less utilization of resources. Check the memory consumption of both before going to the idle state and after going to idle state.
You can configure the same in the applicationHost.config file as shown here –
So a combination of idleTime-out action and the app initialization feature illustrates a quick startup time for the application.
Enhanced Logging in IIS 8.5
IIS 8.0 has some logging features which are configurable. But this logging system has very limited capabilities. For example, it provides you the standard logging capabilities which we cannot extend or customize during logging. The administrator of IIS has very limited options. Take a look at the following IIS 8.0 logging screen –
Now let’s compare the same Logging Fields screen in IIS 8.5.
As you can see, we can add a custom field while configuring logging:
Add the field name and choose the Source Type. It gives us three different options –
- Request Header
- Response Header
- Server Variables
I chose the source type as “Server Variables” and the source as “REMOTE_ADDR. Make sure to click the Apply button in the Action pane on the right hand side as shown here:
Once you apply the changes, make a request to the site and check the log files. The log files are generated under “C:\ inetpub\logs\LogFiles” [your system drive] as shown here:
Now IIS administrators have the choice of adding custom fields within the Request Header, Response Header and/or Server variables to IIS logging, to extend the logging capabilities.
Event Tracing for Windows (ETW) in IIS 8.5 in the Logging Process
Earlier versions of IIS had fewer logging capabilities and IIS took some time to flush the log data into log files. Hence administrators could not monitor IIS logging information in real time. We also just saw that the log data is plain text which increases the time to process and analyse them. In IIS 8.5, administrators can now send logging data to ETW. You as a developer can create your own custom tools to read the data or use some ETW tools to analyse the logging data.
I am using Microsoft Message Analyzer tool to see real-time logging information. Let’s first configure IIS log to send the information to ETW as shown here –
Please note that this configuration is now not going to log the information in log files.
Do not forget to click the Apply button in the Action pane on the right hand side. Now start Microsoft Message Analyzer and configure it for Microsoft – Windows – IIS – Logging as shown here –
Click the button Start With located on the right hand bottom side –
Make some requests to the website and check the Microsoft Message Analyzer. You should now see the log information as shown here –
I made 5 requests. Now double click any one of the request and you will see information about the logging as shown here –
This way with ETW support in IIS 8.5 turned on; events are shown immediately as event tracing is now built-in. It’s a very important feature for IIS admins to better monitor IIS in real time.
Most of the changes in IIS 8.5 reflect the Microsoft Cloud OS initiative that’s in full swing. In the coming versions, it will be interesting to see how IIS fits into cloud-based scenarios!
This article has been editorially reviewed by Suprotim Agarwal.
C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.
We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).
Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.
Click here to Explore the Table of Contents or Download Sample Chapters!
Was this article worth reading? Share it with fellow developers too. Thanks!
Pravinkumar, works as a freelance trainer and consultant on Microsoft Technologies. He is having over 10 years of experience in IT and is also a Microsoft Certified Trainer(MCT). He has conducted various corporate trainings on all versions of .NET Technologies including .NET, SharePoint Server, Microsoft SQL Server, Silverlight, ASP.NET, Microsoft PerformancePoint Server 2007 (Monitoring). He is passionate about learning new technologies from Microsoft. You can contact Pravinkumar at dabade[dot]pravinkumar [attherate] gmail[dot]com