Skip to content

Comment on Ask HN: How do you do realtime

Comments

Technically, the simplest way to do this is via polling+ajax. In our project we implement this as follows:

Every n minutes, the clients polls for updates. It sends along a marker token. The token is either a timestamp it has previously received from the server, or a serialized/json version of the "client model". A while ago, I posted a quick writeup on why you'd need a serialized model here: http://stackoverflow.com/questions/602322/differential-ajax-...

I believe Gmail uses a Comet approach (keep http connections open for a while, and send updates at they happen), but this can be tricky to implement, especially when using something like Google App Engine that places strict deadlines on request handlers.

sidOP

I also tried it this way and it works well. i was sending back the timestamp and the current state and it was quite easy to implement using setTimeout and recalling it again x-minutes later to check if the server state is now different to the client state.

I guess the issue at the moment is we are pretty much a poor startup and worried that it would put stress on the little resources we already have by making the servers handle requests that are not actually doing anything except comparing state of the client and the server.

I was also kind worried that some corporate networks might block my IP/domain name because it may detect the polling as some sort of malicious data being sent back.

I think after V1 is released if we can become atleast ramen profitable i might start to look at implementing this functionality using gmails approach as we may then be able to afford more servers.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.