The information about the number of active user sessions is vital for determining and expecting the server load. It also helps you to determine the perfect time for maintaining the server. In addition, you can choose the right time for making the website update.
You can see the number of active user sessions on the IIS site by using the Performance Monitor tool for your Windows hosting. You just need to set a number of counters. There is another way of doing it with the PowerShell. You will find all the details in this article.
Seeing the Number of Active User Sessions on IIS Site with the Performance Monitor Tool
- Press Windows + R button. Type perfmon and hit the Enter button.
- Now, you have to add the relevant counters for seeing the number of active user sessions. To do it, click on the green “+” button on the toolbar.
- Find the Web Service group. Expand it. You will see a list of available counters. For this tutorial, we will be utilizing the following ones:
- Current Anonymous Users
- Current Non-Anonymous Users
- Current Connections
- Choose your desired counter. Select your IIS website in the field of Instances of selected objects. Click on the Add>> button. The counter will be added instantly.
- Do the same thing for all the required counters. Click on the OK button.
- Now, you will see a variety of real-time information related to the active user sessions in the Performance Manager console. You will see the counters that you had added in the bottom pane.
The Performance Monitor tool allows you to add your custom counters to the console. You can save them in a different view for later usage.
Seeing the Number of Active User Sessions on IIS Site with PowerShell
- Open PowerShell.
- Insert the following command:
(Get-Counter -ListSet 'Web Service').counter
- To know the number of active sessions on your website (Site1), write this line:
Get-Counter "web service(Site1)current connections" -ComputerName web-srv01
- If you want to check the number of connections on your website locally, use this command:
Get-Counter "web service(Site1)current connections" -ComputerName $env:COMPUTERNAME
Here, you are using the environment variable COMPUTERNAME, as specifying the localhost is not allowed.
- If you want to know the current connections on the entire IIS server, type this line:
((Get-Counter -Counter 'web service(_total)current connections' -computer $env:COMPUTERNAME) | Select-Object -Expand countersamples).Cookedvalue
In this article, you have learnt to see the number of active user sessions on your IIS site using the Performance Monitor tool and PowerShell. Now, you can easily analyze the data and take important decisions about maintaining the website at the right time.