

Ask HN: How to sync up the experience for large number of users of a web app? - staunch

What's a reliable method for making sure that if 1,000 people are all using my web app to participate in the same thing that what they're seeing is always within a second or two of being totally in sync?<p>I'm looking for kind of a generic solution, but in the simplest scenario: Over the course of a minute I want to show 3 different pictures and when each one changes it should update on every user's screen at the same time regardless of when they loaded the page.
======
dxjones
First, you need each instance of your running web app to be synchronized to
the same clock, so they can make events occur at the same time.

Second, it would probably be best to upload your images from your server to
your 1,000 clients before they need to be displayed. This can be done
asynchronously, so you server doesn't struggle to get it all done within a few
seconds.

Third, your web app clients could handshake they received the images, ... or
you could just allow enough time to pass so you are confident they all have
the images, ... and then they could all flip their displays at a pre-arranged
time.

Voila. Synchronized image display.

~~~
edw519
"First, you need each instance of your running web app to be synchronized to
the same clock, so they can make events occur at the same time."

Or you could just preload the delta between your clock and their clock onto
the client and trigger a javascript event so the client does all the work.

~~~
dxjones
Yes, "preloading the delta between the server clock and the client clock" is
what I had in mind when I wrote "synchronized to the same clock". That is,
synchronized to the server clock.

------
rmc00
You may want to take a look at comet and long polling. With this method, you
can eliminate reliance on a clock (and all the associated headaches).

Using comet/long polling, you can sort of mimic pushing the new pictures to
clients. This could be ideal because it wouldn't matter when users load the
page. Your mileage may vary, however, depending on your specific requirements.

------
rabidsnail
Differential Synchronization: <http://www.youtube.com/watch?v=S2Hp_1jqpY8>

------
mindhacker
Comet (<http://en.wikipedia.org/wiki/Comet_(programming)>) can be used to make
sure that all your clients are in sync.

rupy (<http://code.google.com/p/rupy/>) might be a good place to start.

