This note is inspired by the presentation from Dingding Ye.

A few technology used in real time web, and each of them has valid usage. Careful analysis needs to be done before deciding which one to use, or you could just use Pusher to get started.

§XHR polling

  • Send AJAX request periodically
  • No special requirement for clients and servers

The period is usually more than 10 sec, otherwise it becomes a DDOS attack. Therefore, it’s not so real time.

Use cases: Twitter web client.

§Long polling

Server holds the incoming open for a while, and if the request info is obtained during the waiting period, server could response immediately, so that the latency (the time between the change happens and the time the client receives the change) could be kept minimal.

It degrades to be XHR polling with short period if update is very frequent.

  • No special requirement for clients and servers

Use cases: HipChat, online chatting.

§HTTP streaming

  • Chunked transfer encoding
  • Special server support. (Since it’s standardized in HTTP 1.1, most mainstream servers should support it.)

Use cases: Twitter streaming API.

§Websocket

  • Special support from both clients and servers
  • Quite efficient when it comes to broadcast.

Use cases: Google doc.