News for hackers. Stuff that matters.
Re:Ask HN: How to sync up the experience for large number of... by dxjones on Sunday April 26, 2009 @08:48PM (#580653)
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.

Re:Ask HN: How to sync up the experience for large number of... by twohey on Sunday April 26, 2009 @09:53PM (#580702)
This is one outline, but you need to be aware of edge cases because networks partition and clocks drift. You should make sure that you gracefully handle (or at the minimum aware of) the following cases:

1. Some of your clients lose network connectivity, so when they see an image they respond, but their network drops out.

2. Some clients have incredible clock skew. This can happen due to any number of very improbable events like time zone changes or faulty motherboards, but it does happen.

Distributed synchronization really depends on what kind of experience you are trying to provide.

For example, if you are showing slides and you want everyone to be "synchronized" you could have all clients poll for the next image, load it in the background, and then notify you that they have it. Once all clients have notified you they have the image you would then push out a command to the clients to display this next image.

Your synchronization needs may be totally different if you are trying to provide a different experience. There are some rather fundamental limits on distributed coordination. For a starting point, see "Time, Clocks, and the Ordering of Events in a Distributed System" by Leslie Lamport available at http://research.microsoft.com/en-us/um/people/lamport/pubs/t...

Re:Ask HN: How to sync up the experience for large number of... by edw519 on Sunday April 26, 2009 @08:59PM (#580665)
"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.

Re:Ask HN: How to sync up the experience for large number of... by dxjones on Monday April 27, 2009 @12:06AM (#580830)
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.