gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 08:50:00 25 4
gpt4 key购买 nike

Thomas Marquardt的following文章介绍了IIS如何处理ASP.Net请求,可配置为运行的最大/最小CLR工作线程/受管IO线程,涉及的各种请求队列及其默认大小。

现在按照文章,在IIS 6.0中会发生以下情况:

  • ASP.NET接收来自IIS IO线程的请求,并将“HSE_STATUS_PENDING”发布到IIS IO线程
  • 请求被移交给CLR Worker线程
  • 如果请求具有高延迟,并且所有线程都被占用(线程计数接近httpRuntime.minFreeThreads),则将请求发布到应用程序级别请求队列(此队列是每个AppDomain的队列)
  • 此外,ASP.NET还会检查并发执行的请求数。文章指出,“如果同时执行的请求数量过多”,它将传入的请求排队到ASP.NET全局请求队列中(这是每个工作进程)(请检查更新2)

  • 我想知道什么是“阈值”,此时ASP.NET认为当前正在执行该请求的请求数太高,然后开始将请求排队到全局ASP.NET请求队列中?

    我认为此阈值将取决于最大工作线程数的配置,但是可能会有一些公式基于哪个ASP.NET将确定并发执行的请求数过高并开始将请求排队到ASP.NET。全局请求队列。这个公式可能是什么?还是可以配置此设置?

    更新

    我再次通读了这篇文章,并在“评论”部分中发现了这一点:

    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. The number of requests in this queue increases if the number of available worker threads falls below the limit specified by 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." There is also an ASP.NET performance counter, "Requests In Application Queue", that indicates how many requests are in the queue. Yes, the CLR thread pool is the one exposed by the .NET ThreadPool class.

    2) The requestQueueLimit is poorly named. It actually limits the maximum number of requests that can be serviced by ASP.NET concurrently. 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限制了排队的请求的数量(我假设它将对在应用程序队列中排队的请求数量加上全局ASP.Net请求队列加上当前正在执行的请求数量的总和)并正在执行。尽管这并不能回答原始问题,但它确实提供了有关由于并发请求/高延迟请求数量过多而何时可能收到503服务器繁忙错误的信息。
    (检查更新2)

    更新2
    我在理解方面犯了一个错误。我混淆了IIS 6和IIS 7的描述。
    本质上,当ASP.NET以集成模式托管在IIS 7.5和7.0上时,不再存在应用程序级队列,ASP.NET维护全局请求队列。

    因此,如果认为执行请求的数量很高,则IIS 7/7.5将开始将请求排队到全局请求队列中。这个问题更多地适用于IIS 7/7.5,而不是6。

    IIS 6.0 而言,没有全局ASP.NET请求队列,但以下情况是正确的:
    1. ASP.NET接收来自IIS IO线程的请求,并将“HSE_STATUS_PENDING”发布到IIS IO线程
    2.将请求移交给CLR Worker线程
    3.如果请求具有高延迟,并且所有线程都已占用(线程计数接近httpRuntime.minFreeThreads),则将请求发布到应用程序级别请求队列(此队列是每个AppDomain的队列)
    4.同样,ASP.NET在接受新请求之前会检查排队的请求和当前正在执行的请求数。如果此数字大于processModel.requestQueueLimit指定的值,则将拒绝进入的请求,并出现503服务器繁忙错误。

    最佳答案

    This article可能有助于更好地了解设置。

    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. This setting effectively limits the number of requests that can run concurrently to maxWorkerThreads minFreeThreads. Set minFreeThreads to 88 * # of CPUs. This limits the number of concurrent requests to 12 (assuming maxWorkerThreads is 100).



    编辑:

    在此 SO post中,Thomas提供了更多详细信息和集成管道中的请求处理示例。请务必阅读答案的注释以获取其他说明。

    A native callback (in webengine.dll) picks up request on CLR worker thread, we compare maxConcurrentRequestsPerCPU * CPUCount to total active requests. 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.

    关于asp.net - ASP.NET IIS-请求何时排队?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10929922/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com