Round Robin, long polling, long connection, FlashSocket

Source: Internet
Author: User
: This article mainly introduces round robin, long polling, long connections, and FlashSocket. if you are interested in the PHP Tutorial, refer to it.
  1. Round Robin: The client periodically sends an Ajax request to the server. after receiving the request, the server immediately returns the response and closes the connection.
    Advantage: it is easier to write back-end programs.
    Disadvantage: most requests are useless, wasting bandwidth and server resources.
    Instance: suitable for small applications.

  2. Long polling: the client sends an Ajax request to the server. after receiving the request, the server holds the connection and returns the response information and closes the connection until a new message exists, after processing the response information, the client sends a new request to the server.
    Advantage: no messages are sent frequently.
    Disadvantage: server hold connections consume resources.
    Examples: WebQQ, Hi web edition, and Facebook IM.

In addition, there are also differences between persistent connections and socket connections:

  1. Persistent connection: embed a hidden parameter iframe in the page and set the src attribute of the hidden parameter iframe to a persistent connection request. the server can continuously input data to the client.
    Advantage: messages arrive immediately without sending useless requests.
    Disadvantage: maintaining a persistent connection increases overhead.
    Example: Gmail chat

  2. Flash Socket: embed a Socket-type Flash program JavaScript in the page to call the Socket interface provided by the Flash program to communicate with the Socket interface on the server, after receiving the information sent by the server, JavaScript controls the display of the page.
    Advantage: implement real-time communication instead of pseudo-real-time communication.
    Disadvantage: The Flash plug-in must be installed on the client; non-HTTP protocol, the firewall cannot be automatically crossed.
    Example: online interactive games.

The preceding describes the four request methods and compares their advantages and disadvantages.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above describes the polling, long polling, long connection, Flash Socket, including the content, hope to be helpful to friends who are interested in PHP tutorials.

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.