I have project that allows multiple users to access, and update simultaneously. Before I know about “Reverse AJAX”, I use a Timer at client side to request server every internal. Now I try to change it by using server-push technique.

Here is basic of Reverse AJAX.
1. Polling
Polling is the most obvious solution to the problem. This is where the browser makes a request of the server at regular and frequent intervals, say every 3 seconds, to see if there has been an update to the page. It’s like 5 year old in the back of the car shouting ‘are we there yet?’ every few seconds.
As the name suggests, long polling requires the client to poll the server for an event (or set of events). The browser makes an Ajax-style request to the server, which is kept open until the server has new data to send to the browser, which is sent to the browser in a complete response. The browser initiates a new long polling request in order to obtain subsequent events.
3.Http Streaming (long-lived HTTP)
Http Streaming is different from Long Polling by keeping the connection (until expiration) between client and server even after it delivers the data. In general, this will perform better.
4. Comet
Comet is a really old technology for constantly updating a webpage. The technology requires that the connection between the client and server is never closed. Once the client has requested the web page the server returns the data as slowly as possible, trying to maintain an open connection for as long as possible. It is kind of like phoning up and being put on hold, you are still connected but not very much actual talking is going on
5. Piggyback
As the name suggests, it is the piggy backing of new data on top of an unrelated response to a client’s request. When new information arrives at the server it is stored until the client next makes a request to the server. When the server replies to the request it also adds all the new information which was updated.

We know HTTP protocol is synchronous and stateless. AJAX saves us from synchronous to server and user doesn’t lock down there. But how to solve the “server-push” issue? Good news is Servlet 3.0 is included.

A more interesting and vital use case for the Servlet 3.0 asynchronous feature is server push. GTalk, a widget that lets GMail users chat online, is an example of server push. GTalk doesn’t poll the server frequently to check if a new message is available to display. Instead it waits for the server to push back new messages. This approach has two obvious advantages: low-lag communication without requests being sent, and no waste of server resources and network bandwidth. For more to read Asynchronous processing support in Servlet 3.0!

Exploring Reverse AJAX
Wiki: Reverse AJAX
Changing the Web Paradigm – Moving from traditional Web applications to Streaming-AJAX
A Simple Comet Example: Hidden Frame and Long Polling
Comet: polling, long polling or Http streaming with AJAX. Which one to choose?
High-performance Ajax with Tomcat Advanced I/O

1. Web 2.0 Techs – Comet (Reverse Ajax, Server-side Push)
2. Direct Web Remoting + Reverse AJAX
3. Ajax Dojo Comet Tutorial

update: 03-22-2009
1. Comet Programming: Using Ajax to Simulate Server Push

2. Can’t wait for Servlet 3.0, try this: Atmosphere, a portable AjaxPush/Comet Framework for everyone.

About these ads