What are the differences in backend and frontend?

Asked

Viewed 82 times

3

When we use async and await in the backend and frontend ? Is it better? It’s worse?

Other related questions:

  1. An API, for example in C#, if all methods are async and await, I can say it’s better than if I didn’t use it?
  2. When not recommended to use async and await? Why?
  • 1

    How is there a difference in performance? Async/await has a purpose that is to wait (or not) asynchronous actions. Try to contextualize these questions...

  • @Felipeavelar I think it now makes more sense, thanks for the comment.

1 answer

4


There is no such relationship that you think you have, that is language mechanism to work with asynchronous execution, it knows nothing where it is running this, if it is back or front end.

Contrary to popular belief use async It’s slower than not using. What’s different about it is not blocking the execution and it can give a better user experience, but don’t expect it to be faster just to give the impression of delivering something without preventing other parts of the application from working, its effort is greater than a synchronous execution.

If the execution is too fast async will certainly make your application worse, if it takes too long to respond (they say at least 50ms waiting), and this only serves for IO operations, so it can give a better experience. If it was useful for everything it would be async. Even when they have something async in many cases it is better to use the same synchronous version. You have to test and see if it has advantage.

If you use it wrong, and a lot of people use it wrong, it can get worse in any situation. If you do it wrong, it’s no use testing.

You can start studying the subject at What are Async Methods?. But don’t stop there (mainly follow the links, see the documentation, just be careful because some example has techniques to make wait on purpose, do not copy the code as if it were cake recipe), it is something that needs a lot of understanding before using.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.