是否所有的Web请求的并行执行和异步处理? [英] Are all the web requests executed in parallel and handled asynchronously?

查看:228
本文介绍了是否所有的Web请求的并行执行和异步处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的WebAPI服务控制器,由IIS托管,
而我试图理解它是如何架构的真正的作品:


  1. 在网页客户端同时发送一个异步请求,是在控制的WebAPI并行执行所有这些请求?


  2. 在IIS应用程序池,我注意到队列的大小设置为1,000默认值 - 这是否意味着1000最大线程数可以在该服务器的WebAPI同时并行工作?
    或者该值只与部份IIS队列?


  3. 我读过的IIS保持某种线程队列,这是异步队列发送它的工作?或全部由IIS到的WebAPI服务发送客户端请求被发送同步?



解决方案

您正在寻找的队列大小指定为每个应用程序池进行排队(通常映射到一个W3WP工作进程)请求的最大数量。一旦队列长度超过503服务器太忙错误将被退回。

在每个工作进程,线程数可以/将运行。每个请求的工作进程中的一个线程中运行(默认为最高每处理250线程,我相信)。

所以,从本质上讲,每个要求的是在它自己的线程处理(兼 - 至少,作为兼任线程获得),但对于一个特定的应用程序池中的所有线程(典型值)由一个单一的管理处理。这意味着请求的确,异步执行至于请求本身而言。

在响应您的评论;如果启用了会议(这你可能这样做),那么ASP.NET将排队,以便保持对每个请求的会话锁的请求。试着打在Chrome中你的睡眠动作,然后在Firefox中的快速响应行动,并看看会发生什么。您应该看到两个不同的会话让你的请求,并发执行。

I am using a WebApi service controller, hosted by IIS, and i'm trying to understand how this architecture really works:

  1. When a WebPage client is sending an Async requests simultaneously, are all this requests executed in parallel at the WebApi controller ?

  2. At the IIS app pool, i've noticed the queue size is set to 1,000 default value - Does it mean that 1,000 max threads can work in parallel at the same time at the WebApi server? Or this value is only related to ths IIS queue?

  3. I've read that the IIS maintains some kind of threads queue, is this queue sends its work asynchronously? or all the client requests sent by the IIS to the WebApi service are being sent synchronously?

解决方案

The queue size you're looking at specifies the maximum number of requests that will be queued for each application pool (which typically maps to one w3wp worker process). Once the queue length is exceeded, 503 "Server Too Busy" errors will be returned.

Within each worker process, a number of threads can/will run. Each request runs on a thread within the worker process (defaulting to a maximum of 250 threads per process, I believe).

So, essentially, each request is processed on its own thread (concurrently - at least, as concurrently as threads get) but all threads for a particular app pool are (typically) managed by a single process. This means that requests are, indeed, executed asynchronously as far as the requests themselves are concerned.

In response to your comment; if you have sessions enabled (which you probably do), then ASP.NET will queue the requests in order maintain a lock on the session for each request. Try hitting your sleeping action in Chrome and then your quick-responding action in Firefox and see what happens. You should see that the two different sessions allow your requests to be executed concurrently.

这篇关于是否所有的Web请求的并行执行和异步处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆