Synchronous code VS Asynchronous CODE

Synchronous code VS Asynchronous CODE

Web server able to handle multiple concurrent requests because web servers typically are multithreaded and they can handle multiple threads going on the same time. But we really need to think the term of scalability

Suppose we have 100 users at the same time and calling the same API and executing the same quarry then this moment we blocking our application while we are waiting to quarries to finish this is not very scalable.

So answer for this is Asynchronous code – if we use Asynchronous code the trade does not block and kept open to handle other requests

We return Task of IActionResult – task represent an asynchronous operation that can return a value  

Need to tell our method to wait for the response we use await keyword to do so.

No alt text provided for this image


要查看或添加评论,请登录

Hasitha Madusanka的更多文章

社区洞察

其他会员也浏览了