c# - When should I use Async Controllers in ASP.NET MVC? -


i have concerns using async actions in asp.net mvc. when improve performance of apps, , when not?

  1. is use async action everywhere in asp.net mvc?
  2. regarding awaitable methods: shall use async/await keywords when want query database (via ef/nhibernate/other orm)?
  3. how many times can use await keywords query database asynchronously in one single action method?

asynchronous action methods useful when action must perform several independent long running operations.

a typical use asynccontroller class long-running web service calls.

should database calls asynchronous ?

the iis thread pool can handle many more simultaneous blocking requests database server. if database bottleneck, asynchronous calls not speed database response. without throttling mechanism, efficiently dispatching more work overwhelmed database server using asynchronous calls merely shifts more of burden database. if db bottleneck, asynchronous calls won’t magic bullet.

you should have @ 1 , 2 references

derived @panagiotiskanavos comments:

moreover, async doesn't mean parallel. asynchronous execution frees valuable threadpool thread blocking external resource, no complexity or performance cost. means same iis machine can handle more concurrent requests, not run faster.

you should consider blocking calls start cpu-intensive spinwait. during stress times, blocking calls result in escalating delays , app pool recycling. asynchronous calls avoid this


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -