Filed in: Performance Tags: Performance score


This score tracks the number of thread switches incurred by requests in your application.

Typically, each dynamic request (such as an ASP.NET request) will incur at least one thread switch when the IIS IO thread hands off request processing to the application framework (e.g. the CLR thread pool for ASP.NET requests). Each thread switch introduces additional overhead to due to context switching, and adds a potential queueing point/delay until it is picked up by the next thread.

If your application experiences significantly more context switches per request, it may experience reduced performance, as well as negatively impact server performance due to context switching.

How this score is calculated

This score tracks the number of context switching on each request, and penalizes requests with more than 1 context switch.

Diagnostics

We automatically identify the location of requests with elevated thread switches, and allow you to dig deeper into specific request traces to review where the thread switching is taking place.



Review the traces to identify the specific points during request processing that are triggering thread switches.

Improving this score

If certain areas of your application are exhibiting very high thread switching, review the associated request traces to identify the cause of the extra thread switches. Common reasons may include:

1. Pre-loading request entity (uploads)
2. Sending large responses asynchronously
3. Async modules

Once you identify the module(s) triggering elevated thread switches, you may be able to reduce thread switches by removing those modules, increasing the "chunk" of async work to reduce the number of thread switches, or re-implementing them to operate synchronously (caveat: avoid synchronous processing of blocking IO tasks),

We recommend addressing thread switches if (a) the application/server context switch rate is high, (b) the area of the application with high thread switches has high traffic, and (c) there is a significant number of thread switches per request (e.g. 5 ).




More resources


Want to learn the best techniques for managing your IIS web server? Join our how-to newsletter.
Want to get the best tool for troubleshooting and tuning your web apps? .

Build your skills


Get performance best practices straight from our IIS & ASP.NET experts:


How-to newsletter: 1-2 emails/week with expert IIS & ASP.NET tips.