简体   繁体   English

ASP.NET IIS - 请求何时排队?

[英]ASP.NET IIS - when are requests queued?

The following article by Thomas Marquardt describes how IIS handles ASP.Net requests, the max/min CLR worker threads/Managed IO threads that can be configured to run, the various requests queues involved and their default sizes. Thomas Marquardt撰写的以下文章描述了IIS如何处理ASP.Net请求,可配置为运行的最大/最小CLR工作线程/托管IO线程,涉及的各种请求队列及其默认大小。

Now as per the article, the following occurs in IIS 6.0: 现在根据文章,IIS 6.0中发生以下情况:

  1. ASP.NET picks up the requests from a IIS IO Thread and posts "HSE_STATUS_PENDING" to IIS IO Thread ASP.NET从IIS IO线程中获取请求,并将“HSE_STATUS_PENDING”发布到IIS IO线程
  2. The requests is handed over to a CLR Worker thread 请求被移交给CLR Worker线程
  3. If the requests are of high latency and all the threads are occupied (the thread count approaches httpRuntime.minFreeThreads), then the requests are posted to the Application level request queue (this queue is per AppDomain) 如果请求具有高延迟并且所有线程都被占用(线程计数接近httpRuntime.minFreeThreads),则请求将发布到应用程序级别请求队列(此队列是每个AppDomain)
  4. Also ASP.NET checks the number of concurrently executing requests. ASP.NET还会检查并发执行请求的数量。 The article states that "if the number of concurrently executing requests is too high" it queues the incoming requests to a ASP.NET global request queue (this is per Worker Process) (Please check Update 2) 文章指出“如果并发执行请求的数量太高”,它会将传入的请求排队到ASP.NET全局请求队列(这是每个工作进程) (请检查更新2)

I want to know what is the "threshold value" at which point ASP.NET considers that the number of requests currently executing it too high and then starts queuing the requests to the global ASP.NET request queue? 我想知道什么是“阈值”,此时ASP.NET认为当前执行它的请求数太高,然后开始将请求排队到全局ASP.NET请求队列?

I think this threshold will depend upon the configuration of max number of worker threads, but there might be some formula based on which ASP.NET will determine that the number of concurrently executing requests is too high and starts queuing the requests to the ASP.NET global request queue. 我认为这个阈值将取决于最大工作线程数的配置,但可能有一些公式基于哪个ASP.NET将确定并发执行的请求数太高并开始将请求排队到ASP.NET全局请求队列。 What might this formula? 这个公式可能是什么? or is this setting configurable? 或者此设置是否可配置?


Update 更新
I read through the article again and in the comments sections I found this: 我再次阅读了这篇文章,在评论部分我发现了这一点:

1) On IIS 6 and in IIS 7 classic mode, each application (AppDomain) has a queue that it uses to maintain the availability of worker threads. 1)在IIS 6和IIS 7经典模式下,每个应用程序(AppDomain)都有一个队列,用于维护工作线程的可用性。 The number of requests in this queue increases if the number of available worker threads falls below the limit specified by httpRuntime minFreeThreads. 如果可用工作线程数低于httpRuntime minFreeThreads指定的限制,则此队列中的请求数会增加。 When the limit specified by httpRuntime appRequestQueueLimit is exceeded, the request is rejected with a 503 status code and the client receives an HttpException with the message "Server too busy." 当超过httpRuntime appRequestQueueLimit指定的限制时,请求将被拒绝,并显示503状态代码,并且客户端收到带有“服务器太忙”消息的HttpException。 There is also an ASP.NET performance counter, "Requests In Application Queue", that indicates how many requests are in the queue. 还有一个ASP.NET性能计数器“应用程序队列中的请求”,指示队列中有多少请求。 Yes, the CLR thread pool is the one exposed by the .NET ThreadPool class. 是的,CLR线程池是.NET ThreadPool类公开的线程池。

2) The requestQueueLimit is poorly named. 2)requestQueueLimit命名不佳。 It actually limits the maximum number of requests that can be serviced by ASP.NET concurrently. 它实际上限制了ASP.NET可以同时处理的最大请求数。 This includes both requests that are queued and requests that are executing. 这包括排队的请求和正在执行的请求。 If the "Requests Current" performance counter exceeds requestQueueLimit, new incoming requests will be rejected with a 503 status code. 如果“请求当前”性能计数器超过requestQueueLimit,则将使用503状态代码拒绝新的传入请求。

So essentially requestQueueLimit limits the number of requests that are queued (I am assuming it will sum the number of requests queued in Application queues plus the global ASP.Net request queue plus the number of requests currently executing) and are executing. 因此,基本上requestQueueLimit限制了排队的请求数(我假设它将在应用程序队列中排队的请求数加上全局ASP.Net请求队列加上当前正在执行的请求数)并正在执行。 All though this does not answer the original question, it does provide information about when we might receive a 503 server busy error because of high number of concurrent requests/high latency requests. 虽然这不能回答原始问题,但它确实提供了有关何时因为大量并发请求/高延迟请求而可能收到503服务器忙碌错误的信息。 (Check update 2) (检查更新2)


Update 2 There was a mistake in my part in the understanding. 更新2我的理解中存在错误。 I had mixed up the descriptions for IIS 6 and IIS 7. 我混淆了IIS 6和IIS 7的描述。
Essentially when ASP.NET is hosted on IIS 7.5 and 7.0 in integrated mode, the application-level queues are no longer present, ASP.NET maintains a global request queue. 实质上,当ASP.NET以集成模式托管在IIS 7.5和7.0上时,应用程序级队列不再存在,ASP.NET维护一个全局请求队列。
So IIS 7/7.5 will start to queue requests to the global request queue if the number of executing requests is deemed high. 因此,如果执行请求的数量很高,IIS 7 / 7.5将开始将请求排队到全局请求队列。 The question applies more to IIS 7/7.5 rather than 6. 这个问题更适用于IIS 7 / 7.5而不是6。

As far IIS 6.0 is concerned, there is no global ASP.NET request queue, but the following is true: IIS 6.0而言,没有全局ASP.NET请求队列,但以下情况属实:
1. ASP.NET picks up the requests from a IIS IO Thread and posts "HSE_STATUS_PENDING" to IIS IO Thread 1. ASP.NET从IIS IO线程中获取请求,并将“HSE_STATUS_PENDING”发布到IIS IO线程
2. The requests is handed over to a CLR Worker thread 2.请求被移交给CLR Worker线程
3. If the requests are of high latency and all the threads are occupied (the thread count approaches httpRuntime.minFreeThreads), then the requests are posted to the Application level request queue (this queue is per AppDomain) 3.如果请求具有高延迟并且所有线程都被占用(线程计数接近httpRuntime.minFreeThreads),则请求将发布到应用程序级别请求队列(此队列是每个AppDomain)
4. Also ASP.NET checks the number of requests queued and currently executing before accepting a new request. 4. ASP.NET还会在接受新请求之前检查排队和当前正在执行的请求数。 If this number is greater than value specified by processModel.requestQueueLimit then incoming requests will be rejected with 503 server busy error. 如果此数字大于processModel.requestQueueLimit指定的值,则将拒绝传入的请求,并显示503服务器忙碌错误。

This article might help to understand the settings a little better. 本文可能有助于更好地理解设置。

minFreeThreads: This setting is used by the worker process to queue all the incoming requests if the number of available threads in the thread pool falls below the value for this setting. minFreeThreads:如果线程池中的可用线程数低于此设置的值,则工作进程将使用此设置对所有传入请求进行排队。 This setting effectively limits the number of requests that can run concurrently to maxWorkerThreads minFreeThreads. 此设置有效地限制了可以同时运行到maxWorkerThreads minFreeThreads的请求数。 Set minFreeThreads to 88 * # of CPUs. 将minFreeThreads设置为88 * #CPU。 This limits the number of concurrent requests to 12 (assuming maxWorkerThreads is 100). 这将并发请求的数量限制为12(假设maxWorkerThreads为100)。

Edit: 编辑:

In this SO post , Thomas provides more detail and examples of request handling in the integrated pipeline. 在这篇SO帖子中 ,Thomas在集成管道中提供了更多详细信息和请求处理示例。 Be sure to read the comments on the answer for additional explanations. 请务必阅读有关答案的评论,以获得更多解释。

A native callback (in webengine.dll) picks up request on CLR worker thread, we compare maxConcurrentRequestsPerCPU * CPUCount to total active requests. 本机回调(在webengine.dll中)在CLR工作线程上获取请求,我们将maxConcurrentRequestsPerCPU * CPUCount与总活动请求进行比较。 If we've exceeded limit, request is inserted in global queue (native code). 如果我们超出限制,请求将插入全局队列(本机代码)。 Otherwise, it will be executed. 否则,它将被执行。 If it was queued, it will be dequeued when one of the active requests completes. 如果它已排队,则当其中一个活动请求完成时,它将被出列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM