开发者

Async Controller In HomeController/Index

since Index is the default landing zone for a website, is it a good idea to make the 开发者_如何学Pythonhome controller an async controller?

In what scenario can I take advantage of AsyncControllers?

Thanks,

Ryan


since Index is the default landing zone for a website, is it a good idea to make the home controller an async controller?

No, it isn't a good idea.

In what scenario can I take advantage of AsyncControllers?

When you have actions that perform intensive I/O tasks and for which you could benefit from I/O Completion ports such as database calls, web service calls, ... I would recommend you reading the following article for better understanding the concept. It's about async ASP.NET pages but async controllers work exactly the same.


You should only use asynch controllers when an operation will take a long time to complete. Asynch does not magically give better performance, in fact, it will perform WORSE than a normal controller.

Asynch controllers, however, allow you to make better use of resources, in particular the thread pool. Making a controller asynch allows the thread to be returned to the thread pool to service other requests.

If your request doesn't do anything time consuming, then you're just adding overhead for no reason.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜