Configuring Proper Performance Counters ASP.NET

You need to keep a close eye on your production servers and monitor their performance all the time.The Windows Performance Monitor tool is a great way to keep an eye on important factors that tell you how well your servers are doingWeb and database servers require a different set of performance counters.For example,on a web server you need to monitor Request/Sec, Requests in Application Queue,and Request Execution time carefully.These counters tell you how well the web application is doing.On a database server, you need to keep an eye on Transactions/Sec, Lock Wait, Disk Read/Write time, etc

Monitoring Web Server Performance Counters

Figure shows some common counters that monitor a web server. All these counters give us valuable indications about how well the server is doing.

Anonymous Requests/Sec
Number of requests coming in to the server from anonymous users/sec.Tells you how many users are anonymously browsing the site.

Cache API Hit Ratio
If you are using ASP.NET Cache to store data, it shows the ratio of successful hits to the cache—the higher the value, the better the caching. If it’s too low, then you have too many unique things in the cache,and cached data is not being used well,or you are running low in memory and cache cannot store much more data.

Errors During Compilation
If you have more than zero, you have a page on the site that is not compiling—must be a deployment problem.

Errors During Execution
Number of exceptions thrown.A nonzero value indicates a problem in the code.

Output Cache Hit Ratio
If you are using an output cache on page or user controls, it shows how well the output cache is working.The higher it is, the better the output caching.

Web server performance monitor configuration

Web server performance monitor configuration

Requests in Application Queue
Shows the number of requests waiting in the application queue to be executed.This means users are waiting for requests to execute on the server before they can see anything on the page.

If this is nonzero,then it means:

  • You have slow performing pages that are taking too long so the request queue is getting stuck.
  • Your server has reached its limit.It cannot execute requests as fast as they come in.
  • You have requests that fetch external data and are getting stuck frequently and eating up valuable worker threads.

Request Execution Time
The time it takes to execute a request in milliseconds, so the higher the value,the worse the performance.If requests are spending more than 300 ms on the server, the delay is going to be visible to the user. If it’s higher, then there are some slow performing pages.

Request Wait Time
Millisecond requests have to wait before they get executed. Ideally it should be zero.

Requests Current
Shows requests currently being executed.

Requests Queued
Number of request waiting in the queue. If it’s nonzero, then it means the server is choked up and the ASP.NET Request Queue is full.

Memory: Pages/Sec
Number of paging the OS is performing from RAM to the Paging file. It should be zero.If nonzero,then it means server needs more RAM or there’s too much memory allocation happening.It could be that the server is running too many applications or services.

Physical Disk

Percent Disk Read Time
Shows the disk reads happening. If it’s 100 percent,it means the disk is working at full capacity.If you have a RAID controller where multiple disks are working,this will show incorrectly and sometimes you will see 300 percent. However, the higher the value it is, the higher the disk activity.If you have high disk activity and your application is not supposed to read that much data from the disk, then you have some problem in your code or there’s a program running on the server that is occupying too much disk I/O.

Percent Disk Write Time
Same as Disk Read time but it’s for disk writes.

Avg Disk Queue Length
Number of read/write requests waiting in the controller queue before the controller can perform on the disk. If it’s high,then it means the controller cannot handle that much disk activity. Either the controller is bad or you just have too much disk activity due to some problem in your application, or some other application in the server is doing too much disk activity.The solution is to get faster disks or re-engineer the application code to reduce dependency on the disk I/O.

Percent Processor Time
Shows how much of the CPU is being used. If it’s near 80 percent, it’s time for you to get more hardware or tune your application.

TCPv4 Connections Established
Number of TCP connections open to your server.If it’s too high, then it means too many users are connected to your server at that moment and you might want to load balance the server.

You might also want to decrease the value of HTTP Persisted Connection Time out from IIS Configuration.Persisted connectionskeep connections open.So,if you see too many open TCP connections, decrease the timeout value.An Ajax application will always benefit from a high timeout value because the more browsers can keep connections open with the server, the less it has to close and reconnect. Remember, Ajax applications are quite chatty. So,the higher timeout value helps browsers keep connections open for a longer period.However, the higher value creates scalability issues because the operating system has a limited number of connections.

Web Service

Anonymous Users/Sec
Shows the number of calls being made to the web services.

Bytes Received/Sec
Bytes per second sent to the server from the browser.

Bytes Sent/Sec
Bytes per second sent from server to the browsers on web service calls.

Monitoring Database Server Performance Counters

SQL Server has many performance counters available that can give you a valuable indication about how the database is performing,as shown in Figure

Performance counters for the database server

Performance counters for the database server


Ideally, it should be zero indicating that there is no paging between the RAM nd page file.This means the server had adequate RAM. If it’s nonzero for a long period, then you need to add more RAM to server or remove applications or services that consumes RAM.

Physical disk
Just like the web server,the physical disk counters are more important for data base servers because the database requires much higher disk activity than web applications.If the Disk Read/Write is too high, then it means you have slow running queries or a table scan going on. Avg Disk Queue Length indicates how well the controller can handle the load. If it’s too high,then you need to get better hard drives or controllers.

Measures CPU utilization. If it is too high, then there is a slow-running query.

The SQL Agent comprises:

Active jobs
Number of jobs currently running.If nonzero, then a job is running and if you see high CPU or disk activity,then it means the job is responsible for the slowdown of the server.

Failed jobs
How many jobs failed to execute since SQL Server started. If it’s nonzero, a jobs running in the SQL Server Agent is failing. Check each job’s log and see what’s wrong.

job’s success rate.
If not 100 percent, then a job is failing to executeproperly.

SQL Server:Access Methods

Full Scans/sec
Number of table scans being performed. If it’s nonzero,then you need to optimize your database design by implementing a better index and queries that use a better query plan. However, if you have small lookup tables, SQL Server won’t use an index,but instead just scan the whole table. If that happens,do not be alarmed if you see a nonzero value here.

Page Splits/sec
Number of page splits per second that occur as a result of overflowing index pages.

Table lock escalation/sec
Number of times the table lock was escalated,which means queries locking the whole table.This is related to the table scan also:the higher the value,the worse the database performance.You need to check your queries and data base design to make sure they don’t try to lock the whole table.Generally, when you have a query that updates a large number of rows, it’s better for SQL Server to lock the whole table instead of locking so many rows one after another.

SQL Server:Buffer Manager

Buffer cache hit ratio
The percentage of pages found in the buffer pool without incurring a read from disk.The higher the value it is,the faster SQL Server performs.Add more RAM to the server if it’s not more than 80 percent.

Page life expectancy
Number of seconds a page will stay in the buffer pool without references.The higher the value, the better SQL Server will perform.Increase RAM on the server to increase page life expectancy.

SQL Server:Databases

Log Bytes Flushed/sec
How much data is being flushed to the disk from logs.The higher it is, the more disk write it requires, which gives an indication to how much INSERT/ UPDATE/DELETE activity is going on that makes SQL Server flush logs to disk.It should not be high unless you have a high volume OLTP application.If you sud- denly get a large number of new users coming to the site,this counter will show a high value.

Number of transactions running per second on data base.If this value is too high,then you have a chatty web application that talks too much to the data base.Your goal would be to minimize it as much as possible because this has direct influence on database server’s performance. Better middle-tier caching and reading multiple record sets in one call are two effective ways to reduce database transactions.

SQL Server:Locks

Lock Wait Time(ms)
Ideally it should be zero,meaning there’s no lock that is preventing SQL Server from reading or writing data on tables. If it’s nonzero then you have some poor queries that hold a lock on the table and prevent other queries from working on those tables.

You might also have too many INSERT/UPDATE/DELETE actions going on,which requires SQL Server to lock rows and forces other queries trying to read/write rows to the same table to wait.

The easiest way to decrease lock wait time is to use “SETTRANSACTION ISOLATION LEVEL READ UNCOMMITTED” on your queries.This will not hold a lock on tables.How ever,it’s a calculated risk because queries will then work on un committed transactions that might roll back.For noncritical data,like RSS feeds or a Flick photo XML feed, stored in a database, you can use this isolation level because you don’t have to have 100 percent accurate data all the time.More over, you can use this on the aspnet_users table because it’s unlikely you will have simultan- eous parallel updates on the same user’s data or that you will have to read a user that was deleted by some other request.Try to use this transaction isolation level as much as possible because it miti gates lock time significantly.

Lock Waits/Sec
Number of operations waiting for locks. If it’s nonzero, then queries are waiting because of a bad query holding a lock on tables.

SQL Server:Memory Manager

Target Server Memory (KB)
Shows how much RAM SQL Server would like to allocate.If it’s higher than the Total Server Memory, then it means SQL Server needs more RAM.

Total Server Memory (KB)
Shows how much RAM SQL Server is currently using. If it’s less than the Target Server Memory,then you have more than enough RAM.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

ASP.NET Topics