Real-time Data push in Ajax applications

Source: Internet
Author: User

Http://www.ibm.com/developerworks/cn/web/wa-aj-socket/

Ajax technology has existed for a while, and the Development motivation has been recognized by people. More and more web sites are considering using Ajax for design, and developers are beginning to limit Ajax capabilities. With the emergence of social networks and collaborative reports, a new set of requirements emerged. If another user changes any activity that a user is observing, the user wants to be notified. If if dynamic data, such as stock price, is displayed on a Web site, all users must immediately receive a notification about the change.

These scenarios are a type of question called "server push. Generally, the server is a central entity, and the server will first receive notifications about any changes that have occurred. The server is responsible for notifying all connected clients of such changes. Unfortunately, HTTP is a standard protocol for client-server communication. It is stateless and, in a sense, one-way. All communication in the HTTP scenario must be initiated by the client until the end of the server. However, the requirements in the scenario we mentioned are totally different. For server push, the server needs to initiate communications and send data to the client. No configuration for HTTP protocol, Web Site ApplicationProgramDevelopers use a unique method to bypass these problems. For example, in polling, the client will contact the server at a fixed (or configurable) interval to check whether new updates are available. In most cases, these round robin is purely a waste, so the server does not have any updates. This method does not have no cost. It has two major problems.

    1. This method is a waste of network resources. A tcp socket connection is usually created for each round-robin request (unless HTTP 1.1 sets its keepalive to true, and the previously created socket will be used ). The cost of socket connection is extremely high. In addition, each request must transmit some data over the network. If no update is found on the server, such data transmission is a waste of resources. If other applications are running on the client machine, these Round Robin will reduce the available bandwidth for data transmission.
    2. Even if the request is successful, an update is indeed returned for the client. Considering the polling frequency, such an update is not real-time. For example, if the polling configuration is set to every 20 seconds, an update occurs when a request is just returned from the server. Therefore, this update will not return to the client until the next request arrives in 20 seconds. Therefore, it takes some time for the client to prepare updates for use on the server. Such waiting is unacceptable for applications that need to run in as real time as possible.

Considering these two problems, polling is not the best method for enterprise applications that require key and real-time server updates. In this articleArticle. Each alternative method has its own highlights in some scenarios. I will describe these scenarios and demonstrate a set of UIS that require real-time server pushing.

......

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.