Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are all the web requests executed in parallel and handled asynchronously?

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?

like image 788
AmirTNinja Avatar asked May 24 '14 13:05

AmirTNinja


1 Answers

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.

like image 199
Ant P Avatar answered Oct 23 '22 15:10

Ant P