Presentation taken from Future of Web Apps Boston (http://futureofwebapps.com/boston-2014)
In this talk, Steve will build a system from scratch for cross-device data synchronization in JavaScript. Through demos, he will explore all the things you're probably not thinking about when rolling your own sync engine, like offline caching, change notification, and conflict resolution. Drawing on his experience from Dropbox, Steve will discuss the thorny challenges around sync and how to solve them.
3. “Data synchronization is the process of
establishing consistency among data from
a source to a target data storage and vice
versa and the continuous harmonization
of the data over time.”
– Wikipedia
13. local hash =
crypto.sha256(storage.data or '').hexdigest()
if request.method == 'PUT' then
if request.headers['If-Match'] == hash then
storage.data = request.body or ''
return 200
else
return 409
end
end
19. Diff and merge
• Keep track of a common ancestor
• 3-way merge, git-like:
– Diff server data against ancestor
– Apply patch to client data
– (or something equivalent)
23. Summary
• Syncing is hard, so think about:
– Dealing with concurrency
– Thinking about offline
– Resolving conflicts in a consistent way
• Or use someone else’s platform
(Dropbox!)