Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much async/await is OK? [closed]

In our project we are using async/await for almost 3 purposes (for all of their methods):

  1. Data access layer: where fetching/updating databases (using Dapper).
  2. Cache (Redis): read/write.
  3. ASP.Net MVC 5 controllers.

The question is how much async/await is ok. Is it ok to use them even when reading or writing small amount of data? How about cache and controllers?

Remarks: the project is a little special and it may have about 50,000 requests per second for few hours of a day.

like image 349
Babak Avatar asked Nov 18 '14 06:11

Babak


1 Answers

According to an article I've read:

Async/await is great for avoiding blocking while potentially time-consuming work is performed in a .NET application, but there are overheads associated with running an async method

The cost of this is comparatively negligible when the asynchronous work takes a long time, but it’s worth keeping in mind.

Based on what you asked, even when reading or writing small amount of data?. It doesnt seem to be a good idea as there are over.

Here is the article: The overhead of async/await in NET 4.5

And in the article he used a profiler to check the optimization of async/await.

QUOTE:

Despite this async method being relatively simple, ANTS Performance Profiler shows that it’s caused over 900 framework methods to be run in order to initialize it and the work it does the first time that it’s run.

The question here maybe if you're gonna accept these minimal overheads, and take into consideration that these overheads do pile up into something possibly problematic.

like image 107
DevEstacion Avatar answered Sep 18 '22 12:09

DevEstacion