开发者

usage of await in server side

I know that async library makes asynchronus implementations really easy when you deal with UI. But I can not see any server side us开发者_如何学Goages of it where it can improve performance. In which server side scenarios await can be used to improve performance?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜