我将 log4net 添加到我的应用程序,现在可以在用户浏览我的网站时查看用户事件的线程 ID。是否有关于 IIS7 如何进行线程分配的任何特定算法,或者它只是一个随机数分配(我怀疑它不是完全随机的,因为我的低流量站点显示线程主要在 10-30 范围内)?可用线程数的最大值是多少?我注意到我的调度程序显示了一个奇怪的线程 ID——这有什么原因吗?调度程序是 Quartz.net,id 显示为“Scheduler_Worker-10”,而不仅仅是一个数字。
最佳答案
This解释所有你需要知道的。
摘录:
When ASP.NET is hosted on IIS 7.0 in integrated mode, the use of threads is a bit different. First of all, the application-level queues are no more. Their performance was always really bad, there was no hope in fixing this, and so we got rid of them. But perhaps the biggest difference is that in IIS 6.0, or ISAPI mode, ASP.NET restricts the number of threads concurrently executing requests, but in IIS 7.0 integrated mode, ASP.NET restricts the number of concurrently executing requests. The difference only matters when the requests are asynchronous (the request either has an asynchronous handler or a module in the pipeline completes asynchronously). Obviously if the reqeusts are synchronous, then the number of concurrently executing requests is the same as the number of threads concurrently executing requests, but if the requests are asynchronous then these two numbers can be quite different as you could have far more reqeusts than threads.
所以基本上,如果请求是同步的,则每个请求的线程数相同。各种看这里parameters .
关于c# - IIS7线程是如何分配的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4910159/