Differences between synchronous requests and asynchronous requests in http requests

Source: Internet
Author: User
Tags exit in

For a WEB programmer, if he does not know the synchronous and asynchronous execution modes, he will send an operation statement (query or read a record) to the server, it is dangerous to set the execution result returned by the referenced server or perform the next operation on the result. For a simple process, there will be no major problems, but if a complicated operation process is involved, for example, the subsequent statements on the client are executed after the operation statement is released. However, for various reasons, the server may not be able to execute the operation statement, the result is returned to the client before subsequent statement execution. When a subsequent statement references the execution result of a previous operation statement, it often references an incorrect value because the execution result does not exist, resulting in system errors or deadlocks, therefore, you should carefully select the corresponding request mode based on the actual situation.

First, let's take a look at the definitions of synchronous and asynchronous requests in http requests:

Synchronous request refers to the communication mode in which the sender sends a packet only after the receiver sends a response.

Asynchronous request refers to the communication mode in which the sender continues to send the next packet after the sender sends the data before receiving the response from the receiver.

Although asynchronous execution mode is more difficult than synchronous execution mode, asynchronous mode can implement multi-task parallel execution, greatly improving user experience and program execution efficiency. In application development, you need to determine whether the synchronous mode or asynchronous mode is selected based on the actual situation. When the query or modification to the database is relatively simple, it is enough to select the synchronous execution mode, which can return the result data in a few seconds or less. In addition, asynchronous execution mode is not necessary when the application cannot continue execution before obtaining the result set. It may take a long time to complete the UPDATE or DELETE operations between complex queries, especially between multiple complex tables. In this case, it is best to adopt the asynchronous execution mode, allows you to operate other parts of the program at the same time.

Articles you may be interested in
  • PHP checks whether a request is an AJAX request or a common request.
  • Php extracts the birthday date from the ID card number and verifies whether it is a minor.
  • Difference between execute and query methods in ThinkPHP
  • Php Output Control: understanding the differences between ob_flush and flush
  • Use break, continue, goto, return, and exit in multiple loops in PHP
  • How to Prevent event bubbling in JQuery and Its Differences
  • Differences in the usage of tinyint, smallint, int, and bigint types in mysql
  • Differences between variables and functions in php after the static keyword is added

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.