- The number of threads that can be created is constrained by physical CPU and memory.
- Applications that run into physical limits should rethink the scalability of the design.
- Scalable design principles include keeping the number of running threads equal to the number of CPUs and to use asynchronous I/O completion ports to minimize the number of running threads.
- ASP.NET AuthorizeAttribute is executed without async-await pattern. High load can cause thread starvation. Consider moving authentication to DelegatingHandler that can implement async-await pattern. [Write a test to show this].
- Avoid common problems with timeslicing.
- Thrashing the CPU and memory
- Convoying on locks
- Scale shared resources by replicating or partitioning.
- Use backoff with randomization to avoid livelocks and Thundering herd problem.
“fixed size page file so when the box run out of commit limit (Page file + RAM) windows will not be able to create additional threads for any processes because memory needed for stack space will not be available and system will freeze.”
| where ProviderName contains "Microsoft-Windows-Resource-Exhaustion-Detector"
Log Name: System
Task Category: Resource Exhaustion Diagnosis Events
Keywords: Events related to exhaustion of system commit limit (virtual memory).
Windows successfully diagnosed a low virtual memory condition. The following programs consumed the most virtual memory: X.exe consumed 78804631552 bytes, Y.exe consumed 71854399488 bytes, and Z.exe consumed 16489115648 bytes.