Chapter 11. Parallel, Asynchronous, and Real-Time Data Operations
The web application programming model has traditionally been based on synchronous client/server communication, in which the browser makes an HTTP request and waits for the server to return a response. While this model works well for a majority of scenarios, it can be very inefficient in handling long-running or complex transactions.
This chapter shows you how to take advantage of the powerful asynchronous and parallel processing capabilities in ASP.NET MVC to deal with more complex scenarios, such as asynchronous request processing and the use of real-time communication to send and receive messages to/from many simultaneously connected clients at once.
Asynchronous Controllers
When a request arrives, ASP.NET grabs one of the threads from the pool to handle the request. If the process is synchronous, the thread will be blocked from handling other incoming requests until the current process is complete.
In most scenarios, the process being executed is short-lived enough that ASP.NET can handle a few blocked threads. However, if the application needs to handle a large number of incoming requests or there are too many long-running requests, the thread pool might become depleted, and a condition known as thread starvation will occur. When this happens, the web server will start queuing new incoming requests. At some point, the queue will fill up and any new requests will be rejected, returning an HTTP 503 (server too busy) ...
Get Programming ASP.NET MVC 4 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.