Infolink

 

Search This Blog

Showing posts with label FAQ. Show all posts
Showing posts with label FAQ. Show all posts

Dec 15, 2013

Asynchronous Methods PART-2

Everybody would agree that asynchronously-served requests are important for the performance of potentially-lengthy operations. Taking this point to the limit, Windows 8 is highly dependent upon asynchronous operations and that is the preferred way of coding in the newest platform.

So what’s the real benefit of implementing asynchronous requests?

The benefits of asynchronous requests are entirely for the server environment. In ASP.NET, async HTTP handlers keep the server runtime much more responsive by guaranteeing that a larger number of threads are available at any time to serve requests. In the end, it won’t so much be the requests for long-running tasks that benefit from async handlers, but all other requests, for images, scripts, and other static and ASPX pages. In this way, the site remains highly responsive for all users and long-running requests will still take their time to complete. 

Asynchronous Methods PART-1

In general, use synchronous methods for the following conditions:
  • The operations are simple or short-running.
  • Simplicity is more important than efficiency.
  • The operations are primarily CPU operations instead of operations that involve extensive disk or network overhead. Using asynchronous methods on CPU bound operations provides no benefits and results in more overhead.
  • In general, use asynchronous methods for the following conditions:
  • You're calling services that can be consumed through asynchronous methods, and you're using .NET 4.5 or higher.
 
  • The operations are network-bound or I/O-bound instead of CPU-bound.
  • Parallelism is more important than simplicity of code.
  • You want to provide a mechanism that lets users cancel a long-running request.
  • When the benefit of switching threads out weights the cost of the context switch. In general, you should make a method asynchronous if the synchronous method blocks the ASP.NET request thread while doing no work.  By making the call asynchronous,  the ASP.NET request thread is not blocked doing no work while it waits for the web service request to complete.
  • Testing shows that the blocking operations are a bottleneck in site performance and that IIS can service more requests by using asynchronous methods for these blocking calls.
Related Posts Plugin for WordPress, Blogger...