Comparison of the way of push and pull of Ajax

Source: Internet
Author: User
Tags comparison time interval

Using AJAX, you can develop browser-based Web applications that have high user interactivity and are almost imperceptible to latency. Real-time Dynamic data such as news headlines, stock quotes and auction houses need to be sent to users as quickly as possible. However, Ajax is still limited by the weakness of the Web request/response architecture, making it impossible for the server to push real-time dynamic web data.

Enginbozdag, Alimesbah, and Arievandeursen of the Delft University of Technology discussed the following ways to implement real-time event notifications based on the Web:

1.HTTP Pull method: In this traditional approach, the client checks the latest data on the server at a user-definable time interval. The frequency of this pull method is high enough to ensure high data accuracy, but high frequencies can lead to redundant checks, resulting in higher network traffic. On the other hand, low frequencies can lead to missing updated data. Ideally, the pull time interval should be equal to the speed at which the server state changes.

2.HTTP Flow: This method consists of a server data stream that exists in an uninterrupted HTTP connection response or in a XMLHttpRequest connection.

3. Reverse Ajax: The service stream is applied to Ajax, which is called reverse Ajax or comet. It allows the server to send a message to the client when an event occurs without requiring a client to explicitly request it. The goal is to achieve real-time updates of state changes. Comet uses the characteristics of persistent connections in http/1.1. With http/1.1, the TCP connection between the server and the browser remains connected until one side sends a clear "close connection" message, or a timeout and a network error occurs, unless otherwise stated.

4. Long polling: The so-called asynchronous polling, this way is a pure server-side push and client pull way of the mix. It is based on the Bayeux protocol. This protocol follows a theme-based publish-subscribe mechanism. After you subscribe to a channel, the connection between the client and the server remains open and a predefined time is maintained. If no event occurs on the server side and a timeout occurs, the server side requests the client for an asynchronous reconnection. If an event occurs, the server side sends the data to the client and the client is reconnected.

In their experimental studies, the authors compared data consistency, server performance, network performance, and data loss with an AJAX application using Comet push (Dojo's cometd Library) and a pure pull approach.

Related Article

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.