Implement a real-time server push in Ajax applications

The new range of advanced user interface (UI) applications requires some aspect of the “server-push” feature so clients can be notified immediately of any server-side changes. Unfortunately, the HTTP spec does not address the issue of any server-side initiated communication, so the server-push has traditionally been implemented through client-side polling. This technique tends to generate a lot of unnecessary traffic and non-optimized applications. Thankfully, certain Rich Internet Application (RIA) technologies do allow the opening of a dedicated socket channel, with the back-end server providing an opportunity for Asynchronous JavaScript and XML (Ajax) applications to piggyback on their APIs and implement a server push. This article explores this technique in a variety of ways, and helps you understand it well enough to begin your own implementation.

Introduction

Ajax technology has been around for quite some time now, and the development momentum has really started to pick up. More and more Web sites are being designed with Ajax in mind, and developers have started to push Ajax to its limits. With the advent of phenomena like social networking and collaborative reporting, a whole new set of demands has started to appear. Users like to be notified if any other user has made changes to any activity being watched. Or, if a Web site displays dynamic data, such as stock market prices, then all the users must be notified about the changes instantly.

These scenarios lend themselves to a general class of problem called “Server Push.” Typically, the server is the central entity, which gets notified first of any changes that happen, and it’s the server’s responsibility to notify all of the connected clients about the changes. Unfortunately, HTTP is the defacto standard protocol for client-server communication, and it is a stateless and, in a sense, unidirectional protocol. All the communications in an HTTP scenario must be originated by a client and ended by the server, whereas the scenario that I am explaining requires the reverse. For a server push, I want the server to start the communication and send the data to the client. The HTTP protocol has no provision for this, and Web site application developers use ingenious ways to circumvent these problems, such as polling, where a client keeps contacting the server at a fixed (or configurable) interval of time to find if any new updates are available. Most of the time, these polls will be wasteful because the server will not have any updates. This does not come for free, and there are two problems associated with this approach.

Posted by VenkataSundar-M on 23 September 2009

Read more at: http://www.ibm.com/developerworks/web/library/wa-aj-socket/index.html

 

 

 

You can leave a response, or trackback from your own site.

2 Responses to “Implement a real-time server push in Ajax applications”

  1. cocktail party says:

    I enjoyed your helpful article. topnotch contribution. I hope you write many. I will continue watching

  2. warp_net_site says:

    Great information…

    This is first-class. Every stare upon this offer matter therefore we are confused. We are attracted to this sort of issues. Person appreciate ones accumulate, and profit your precious time with this. Please keep editing. They are very worthy facts and…

Leave a Reply

Designed for Ares Galaxy in Collaboration with Hostgator coupons and Popular Wordpress Themes and unlock iphone 5