Monday, June 13, 2011

Apple's iCloud and Synchronization

Apple’s iCloud promises to keep your devices in sync so that you can use your Mac, iPhone, iPad, PC and iPod Touch without worrying about synchronization issues. No matter how that’s implemented, it’s going to be a big step up from synchronizing everything through iTunes over USB. But I’d like to know more.

What’s Been Said and Written

During the WWDC Keynote, Jobs said “the truth is in the cloud.” This could mean a lot of things, but people have been attempting to interpret it.

John Gruber paraphrases:
The gist is that Apple considers syncing to mean peer-to-peer — something where every device is on equal footing. With iCloud, there is one official data store: iCloud’s. As Jobs put it on stage, iCloud’s data is “the truth”. This means no conflicts or merging.
I don’t yet know how iCloud will work, and I can’t read John Gruber’s mind, so I don’t really know what he meant by what he said. The only way I can see iCloud avoiding conflicts and merges is if you can only modify shared data when you’re directly connected to iCloud. As soon as you allow for the possibility that you can make a change on a device that isn’t performed in lockstep with iCloud, you step back into the world of conflicts and merging.

There may be iCloud API documentation that covers this in detail, or WWDC sessions that expounded on the subject. I don’t know. I wasn’t at WWDC and I’m not a paid member of either of Apple’s developer programs[1].

iCloud-Only Changes

One possibility is that Apple will not allow you to change data that is stored in iCloud unless you’re directly connected to iCloud. For instance, if I wanted to change a Calendar event on my iPad, and I were connected to iCloud, I could make the changes. The changes would be stored in iCloud, and be broadcast to all iCloud-connected devices.

For instance, if I had an iPhone, iPad and Mac, all connected to the cloud, they might all start with the same piece of data (e.g. a calendar event), which I’ve marked with a '1’. The phone could request a change (’2’), which would be stored in iCloud and broadcast to the devices:



If I were to try and make a simultaneous change on another device, the broadcast from iCloud could simply overwrite it, or it could ask the user to make a decision.

This approach is technically possible, but not terribly likely. This would imply that if you have a laptop or an iPad without 3G service and you’re not currently on a network, you cannot make changes to your calendar or anything else stored in iCloud. That’s too limiting to make sense.

Offline Changes

If Apple is going to allow users to make offline changes — changes that can’t be immediately verified and stored in iCloud — then it seems like they also need to deal with conflicts and merges.

If you can make offline changes, and “iCloud’s data is 'the truth’”, then as soon as you reconnect to iCloud, your device will see that iCloud’s data is different than the data stored in your device and immediately overwrite it with the older version from iCloud. That’s actively worse than iCloud-only changes, because you can make all the changes you want when you’re not connected to iCloud, but they’ll all be lost:



If you make a change on a single device while offline, when you come back online, the changes could be pushed to iCloud and broadcast to all other devices connected to iCloud without having any conflicts or merges.

Similarly, if a change is saved to iCloud from one device while another device is offline, when that second device reconnects, the changes from iCloud can be broadcast to it without any conflicts or merges.

However, if two devices make a change to the same piece of data while one or both of them is offline with respect to iCloud, then things get more complicated. Either you have two unrelated changes to a single piece of data (for instance, you change the location of an event on one device and the date of the event on another device), which we’ll call a 'merge’ or you have you have two changes that disagree with each other, a 'conflict’.



Merging without conflicts is usually not too troublesome, but as soon as you have two conflicting changes, you must either make some hard decisions about which version of these changes from two devices is the 'best’ (for instance, the most recently-recorded change) or you must break the seamless user experience and ask the user which change is the best. The former will likely lead to you making the wrong decision now and again, whereas the latter is very hard to do in a way that’s not confusing to all but the most technical of users.

Saying that 'the Cloud is the truth’ doesn’t measurably change any of that complexity.

It Just Works

What you could argue is that while merges and conflict are unavoidable[2] and have the potential to be both complicated and confusing[3], Apple could conceal most if not all of that from the end user and even the developer who’s using the iCloud APIs.

Apple likes to build complex systems that offer a simple and clean user experience, so this makes some sense to me. Not only does this sound like an approach Apple might take, it sounds a lot like the approach they already take with Sync Services, as Weldon Dodd wrote for GigaOM.

Sticking with our Calendar Event example, if you make changes to your calendar event in one or more devices, some of which may have been offline at the time, either simultaneously or at different times in the day, iCloud will decide for itself which version represents the truth and present that information to any iCloud connected device. It’s possible that neither the user nor the developer will have any say in the matter. If what you end up seeing matches what you think is the right final value — and most of the time you probably will — then you’ll believe that it “just works.” As MG Siegler put it for TechCruch:
With iCloud, Apple is transforming the cloud from an almost tangible place that you visit to find your stuff, to a place that only exists in the background. It’s never seen. You never interact with it, your apps do — and you never realize it. It’s magic.
If this is the case, then the means by which conflicts are reconciled and merges are performed may remain a black box, even to well-informed iOS and OS X developers. And if Apple’s done a sufficiently good job, no-one will ever mind.


  1. And if I were a member of the developer programs or a WWDC attendee, I’d be bound by NDA, and unable to share what I know.  ↩
  2. They are.  ↩
  3. They do.  ↩

1 comment:

  1. I see MacStories has a transcript of The Talk Show #47 where Gruber elaborates on his viewpoint, which is definitely in the "It Just Works" category.

    ReplyDelete