Question

I know that async library makes asynchronus implementations really easy when you deal with UI. But I can not see any server side usages of it where it can improve performance. In which server side scenarios await can be used to improve performance?

Was it helpful?

Solution

Async is particularly useful in network scenarios, since communication between servers is rarely without latency. Making a request to another webserver (another tier, a third party REST service) or even querying the database are usually done with blocking calls that stop the current thread from doing any work until the remote call has completed. By being able to await the remote call instead, your current thread is freed up to handle other requests, reducing memory pressure (IIS uses 256KB of stack space per thread) and increasing potentials loads (more parallel tasks can run before you run out of threads).

Most of the basic plumbing of ASP.NET uses IHttpHandler rather than IHttpAsyncHandler, which means it presumes blocking behavior, but it's possible to use async in ASP.NET.

OTHER TIPS

Using async versus using the existing async call API will not make your applications suddenly perform better, it only makes writing and maintaining the code more manageable. This is not the right question to be asking.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top