Is "long polling" the most efficient way to create a Web Real Time App?
Asked Answered
P

3

11

I want to create an application like this:

http://collabedit.com/

What is the most efficient way to create this real time application?

Flash? Long polling? Http Streaming? or something else?

Thanks ;)

Punke answered 13/3, 2010 at 21:39 Comment(0)
W
14

For now, long polling is probably the best solution. Many big-name sites have long polling implementations, including Facebook, Google and eBay. Not everyone has Flash installed/enabled in their browsers. In the future Web Sockets might be able to do an easier job of it for us.

Update: As of this writing, the WebSocket API is implemented in the latest WebKit (Chrome/Safari) and Firefox 4 beta. There is also a public snapshot build of Opera available for download with an implementation of the API. This means testing the API is widely available. For more information, see this answer.

Wadley answered 13/3, 2010 at 21:43 Comment(7)
+1 I like long polling. The future might be different but I wouldn't go with Flash.Elysia
I have used phpfreechat ( that use long polling ) and with only 20 people is very very very slow !! Why ? I need to create a real time app for million of people simultanely !!Punke
@xRobot: Have you checked the FAQ? [phpfreechat.net/faq] It offers a solution for one performance issue related to disk access. Other than that you require a very high powered server to handle millions of connections at the same time. Normal http requests are open->get data->close, so simultaneous connections are fewer. With long polling it's open->wait for data->close, so many simultaneous are almost guaranteed. Servers can only handle a limited amount of concurrent connections, and you get what you pay for, if you catch my drift!Wadley
I don't think Google use Long-Poll to implement Comet. At least, GMail implements comet with XHR-streaming.Scleroma
@Morgan Cheng: Right you are. I heard that XHR-streaming was problematic with Internet Explorer, but it appears Google found a way around that. alex.dojotoolkit.org/2006/02/…Wadley
+1, the best way to do that's completely cross-browser is long-polling, which is implemented in a number of comet servers. The hack mentioned for gtalk is htmlfile streaming, which is different and has its own limitations: cometdaily.com/2007/11/18/ie-activexhtmlfile-transport-part-iiExocentric
While recent webkit might support it, old infrastructure appliances in the middle might still block the WS protocol. It's reasonable to consider falling back on xhr-polling.Replica
S
4

All the different methods have different pros and cons, I'm not an specialist on the differences, that's why I'll recomend you to avoid making the choice, avoid the development and tuning that each approach involves, avoid the future changes in available technologies (ie. as HTML5 web sockets arrival), using a library that abstracts the transport method used, and chooses the best approach based on client capabilities:

http://socket.io/

this wonderful library makes creating realtime apps amazingly simple! and there are various server-side implementations: Python (Tornado), Java, Google GO, Rack (Ruby), besides the mainstream implementation in Node.js (server-side JavaScript)

Secondbest answered 3/5, 2011 at 19:9 Comment(1)
Yup..!! Already used it with both Java and NodeJS. its brillient tool. For java we can use netty server implementation.Devout
S
1

I don't think long-polling is most efficient way to do Comet. Anyway, it sends new HTTP request after response is got. It cost more extra HTTP requests than HTTP streaming.

But, long-polling might be more reliable and easier to implement than HTTP streaming. According to this article in Google Code, HTTP streaming might not be functional if intermediate HTTP proxy buffers content.

It is interesting that GMail doesn't use long-polling. With the help of Http sniffer, it is clear that it uses HTTP streaming for Comet.

Scleroma answered 22/3, 2010 at 8:43 Comment(3)
Also Facebook don't use long polling ? Do you know any example for http streaming ? Thans ^_^Punke
I haven't test it personally, but I'm told that Facebook chat is implemented by long-polling. GMail is Http Streaming. So is Outlook Web Access.Scleroma
@xRobot, if you are looking forward to how-to, this URL is a good summary: cometdaily.com/2007/12/11/…Scleroma

© 2022 - 2024 — McMap. All rights reserved.