How to quickly estimate the current number of user sessions on the IIS website running on Windows Server? Such information will allow to determine and predict the load on the server, choose the best time for the maintenance and updates of the website.
The easiest way to determine the number of active user sessions on the IIS Web site using performance counters in Windows Performance Monitor.
Open the Performance Monitor console by running the perfmon command and go the Performance monitor section (Monitoring Tools — > Performance Monitor).
Then you have to add the necessary counters to the monitor window. (By default, the general CPU load counter is displayed, but you can remove it.) To add a new counter, click the green button on the toolbar (you can see it on the screenshot) or press Ctrl+N on the keyboard.
In the list of available counters, find and expand the Web Service group.
We need two counters here:
- Current Anonymous Users is the number of anonymous IIS users
- Current Non-Anonymous Users is the number of authorized IIS users
Select the desired counter and in the Instances of selected objects choose one or more IIS websites, for which you want to display information. The information about users of all websites on the server is stored in the _Total instance. Now you only have to click the Add >> button to move the counter to the list of the counters to be added in the right pane.
Add all the necessary counters in the same way and click OK.
Now in the Performance Manager console, the information about the number of user sessions is displayed in the real time (by default, the counter values are displayed as linear diagrams). If you select any of the counters in the bottom pane, you can view its last, average, minimum or maximum value for a period of time.
You can add custom performance counters to this console and save them in a single view, which can be used to quickly access the web server load data.
You can access the performance counter data from Powershell.
The list of all available Web Service counters can be displayed as follows:
(Get-Counter -ListSet 'Web Service').counter
To get information about the current number of anonymous users (the counter \Web Service(*)\Current Anonymous Users), use this command:
Get-Counter -Counter “\Web Service(*)\Current Anonymous Users”
Get-wmiObject -class Win32_PerfRawData_W3SVC_WebService | select-object -expand currentanonymoususers