I am a little bit new to ASP.NET MVC, after searching I still have one thing don't understand. Why async controller needed? Since every HTTP request will cause the sever to create a new instance of controller, so the server doesn't block any request, then why need an async controller?
-
Chances are unless you're dealing with a server that gets a lot of requests (like SO) you won't see too much benefit to its blocking prevention.Brad Christie– Brad Christie2012-11-08 13:42:58 +00:00Commented Nov 8, 2012 at 13:42
-
Thank you for pointing out this, what should I do with this, delete it?Shuping– Shuping2012-11-08 14:00:30 +00:00Commented Nov 8, 2012 at 14:00
-
You can close to vote your own question too.Marijn– Marijn2014-03-05 12:08:28 +00:00Commented Mar 5, 2014 at 12:08
1 Answer
The whole point of Async Controllers is to free the IIS threads while long operations are performed. IIS threads are pulled from the .NET thread pool. The maximum number of thread pool threads will vary depeding on your system configuration (on my core-2-quad it's 1023). That means that long operations will consume one of these threads. When the maximum number is reached, additional requests may have to wait until one is freed. To put it very clearly: If you have 1023 actions executing long polling requests, your web-site will stop responding to additional requests.
When you use Async Controllers, you can create threads outside the thread pool and, thus, going around this max threads limit.