In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what is the difference between asynchronous request and asynchronous call". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. let's study and learn "what's the difference between asynchronous request and asynchronous call"!
The difference between an asynchronous request and an asynchronous call
In the article mentioned above, there are two paragraphs about the difference between an asynchronous request and an asynchronous call:
Difference 1: asynchronous requests are used to solve the pressure caused by concurrent requests on the server, thus improving the throughput of requests, while asynchronous calls are used to do some non-mainline processes and do not require real-time calculation and response, such as synchronous logs to kafka for log analysis.
Difference 2: asynchronous requests will always wait for the corresponding response and need to return the result to the client, while asynchronous calls will often be returned to the client immediately to complete the entire request. As for the task of asynchronous invocation, it is OK to run in the background, and the client will not care.
After careful reading and analysis, the asynchronous request mentioned in this article should refer to the asynchronous processing of business through the AsyncContext object of Servlet or Callable, DeferredResult, WebAsyncTask, and so on in Spring. The asynchronous invocation in this article refers to an asynchronous method similar to calling the @ Async annotation in Spring.
Do you think it makes sense when you look at the difference between the two concepts above? Does it feel like you have successfully distinguished an asynchronous request from an asynchronous call?
So, have you ever thought about the question, don't we usually say that requesting an interface is the same as calling an interface? How does it become two completely different concepts here?
Inquiry into questions
With the above questions, start to search with search engines. It is found that when searching for "the difference between asynchronous requests and asynchronous calls", the content found is basically from the above articles and derivative articles, or about the difference between asynchronous and synchronous. This does not mean anything, but it also shows that the difference between the two concepts has not been generally recognized.
So I began to try to search through English search engines. I searched "the difference between asynchronous call and asynchronous request" first and didn't get the desired results. Most articles still talk about the difference between async and synchronization.
Change the keyword to search for "the difference between asynchronous call and asynchronous method", and the result is the same, and there is no desired article. But a related problem on Stack Overflow, "Synchronous Vs Asynchronous related to web services", was found.
Two phrases appear at the bottom of the question: Asynchronous service and Asynchronous calls. If you take a closer look at the explanations of the two phrases, you will find that it is the desired result.
Asynchronous invocation and Asynchronous Service
In fact, it has been found in the process of English search that the two phrases asynchronous request and asynchronous call often appear when discussing the difference between async and synchronization, and they are both talking about the difference between async and synchronization, but not the difference between them. So whether an asynchronous call or an asynchronous request is essentially the same thing.
However, the difference between asynchronous request and asynchronous call mentioned in the article "Asynchronous request and Asynchronous invocation in SpringBoot" is not conceptually clear what is asynchronous request and what is asynchronous call. And only those articles say so, so you can think of asynchronous request and asynchronous invocation as the same concept (asynchronous call). By "asynchronous invocation", the author refers to an asynchronous service (Asynchronous service).
In order to further prove the above conclusion, we will briefly translate the explanations of the two concepts in the Q & A below.
Asynchronous service and Asynchronous calls
Asynchronous service
It takes a lot of time to execute your web service, such as reading a large file from the file system. At this point, if you use a "synchronized" web service, the client must wait for the processing to complete, which usually blocks threads and causes performance problems for highly concurrent services.
If the web service is set to be asynchronous, you can delegate the time-consuming service to another thread or use a non-blocking mechanism to return at some point in the future. Also take reading large files as an example, you can use the asynchronous ReadFile method to read large files. This avoids thread blocking and improves throughput.
Asynchronous calls
It is worth noting that you can invoke a non-asynchronous service asynchronously. For example, the call to Ajax in JavaScript:
Var jqxhr = $.ajax ("AnyService.svc") .done (function () {alert ("success");}) .fail (function () {alert ("error");}) .always (function () {alert ("complete");}); alert ("Called")
To execute the above example, first show "Called" and then show "success", because you don't have to wait for the result returned by the service during execution. And the invoked service does not need to be asynchronous.
In short, the asynchronous and synchronous characteristics of the service implementation are completely independent of the asynchronous and synchronous characteristics of the client invocation. In other words, the client can invoke the synchronous service asynchronously, and the client can also invoke the asynchronous service synchronously.
Thank you for your reading. this is the content of "what's the difference between asynchronous request and asynchronous call". After the study of this article, I believe you have a deeper understanding of the difference between asynchronous request and asynchronous invocation. Specific use also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.