Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make WebAPI actions async?

I've got a question about whether it's beneficial to use async/await on WebAPI / MVC Controller AJAX requests.

Say I've got this AngularJS app that talks to a WebAPI backend and I want to get some data. I do some AJAX call to WebAPI and wait for the results.

In terms of the client, this is of course Async. Would it now be beneficial for the server if I was to make these actions Async?

EDIT

I just found this: http://www.dotnetcurry.com/showarticle.aspx?ID=948 - saying it IS

EDIT - attempt to clarify Let me try to be more clear. Will the processor load on the server be less if I implement all the calls to the service layer from my WebAPI as async (the .NET keyword) vs. 'normal'?

Will IIS spawn more threads in case all the methods are NOT Async, thereby using up more memory for instance?

like image 318
Jochen van Wylick Avatar asked Feb 14 '23 10:02

Jochen van Wylick


1 Answers

If your action method hits a database or filesystem, or makes another network request (i.e. something that requires waiting on IO) then making the action async will have some benefit if your server is under heavy load.

like image 65
Darrel Miller Avatar answered Feb 21 '23 03:02

Darrel Miller