Differences between synchronous requests and asynchronous requests

Source: Internet
Author: User

Differences between synchronous requests and asynchronous requests

 

First, explain the concepts of synchronization and Asynchronization.

Synchronization refers to the communication mode in which the sender sends a packet only after the receiver sends a response.
Asynchronous means that the sender sends the next packet instead of sending the response from the receiver.

 

Concepts of synchronous communication and asynchronous communication

Synchronous communication requires both parties to use the same clock frequency for accurate coordination. By sharing a single clock or timed pulse source, the sender and receiver can be accurately synchronized, which is highly efficient;
Asynchronous communication does not require synchronization between the two parties. The receiving and receiving parties can use their respective clock sources. Both parties follow the asynchronous communication protocol. The time interval between sending characters by the sender is not certain because the characters are data transmission units, transmission efficiency is lower than synchronous transmission efficiency.

 

The communication options used by the user to call Web Services: synchronous or asynchronous.

Users can call services synchronously or asynchronously. From the user's point of view, the difference between the two methods is:

    • Synchronization-- The user calls the service through a single thread. The thread sends a request, blocks the service during running, and waits for a response.

    • Asynchronous-- The user calls the service through two threads. One thread sends a request while the other thread receives a response.

TermsSynchronizationAndAsynchronousOftenSequenceAndConcurrencyConfused. The following two terms are related to the sequence in which a separate task must be executed.SynchronizationAndAsynchronousIt is related to the way the thread executes a single task (such as calling a single service. A good way to understand the differences between synchronous and asynchronous calls is to consider the consequences of crash recovery:

    • Synchronization-- If the user crashes when the service is blocked during running, when it restarts, it will not be able to re-connect to the ongoing call, so the response is lost. The user must repeat the call process and expect that the call will not crash this time.

    • Asynchronous-- If the user crashes after the request is sent and waits for a response, the user can continue to wait for the response when it restarts, so the response will not be lost.

Crash recovery is not the only difference between synchronous and asynchronous calls, but if you try to determine which method a call uses, consider how each call handles crash recovery, this usually gives you a good answer.

++ ++

When using Ajax in Java Web development, it is important to fully understandSynchronizationAndAsynchronousDifferences between communication models (see references ). Lack of support for asynchronous communication models affects client development, integration with Web frameworks, usage of tag libraries, IDE usage, and thread behavior.

 

In the synchronous request/response communication model, a browser always initiates a request (through a Web user) (opposite to a Web server, application server, or web application ). Then, the web server, application server, or web application responds to the incoming request. You cannot continue using the browser when processing synchronous request/response pairs.

 

In the asynchronous request/response communication model, the communication between a browser (through a Web user) to a Web server, application server, or web application (and vice versa) is decoupled. In the processing of asynchronous requests/responses, web users can continue to use browsers when the current asynchronous request is processed. Once the asynchronous request processing is complete, the asynchronous response is sent back to the client page (from the Web server, application server, or web application. In typical cases, calls do not affect web users; they do not need to wait for a response.


This article is from the "Java technology" blog, please be sure to keep this source http://328686937.blog.51cto.com/8846469/1568663

Differences between synchronous requests and asynchronous requests

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.