O'Reilly logo

Programming ASP.NET MVC 4 by Hrusikesh Panda, Jess Chadwick, Todd Snyder

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required