Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

TouchDB vs iCloud

snej edited this page · 1 revision

I was recently asked to describe what advantages TouchDB has over iCloud (Apple's document and data sync system for iOS and Mac apps.) Here's what I wrote.

Conflict Resolution. I'm really not sure what iCloud does about conflicts; I couldn't find a description in the Apple docs. This is important and hard to get right. The app is ultimately responsible for merging changes within a record, but the sync framework needs to identify the conflicting revisions. TouchDB (like CouchDB) tracks revision histories and propagates a tree of revisions, which is the most reliable way to do it.

Flexible Schema. iCloud's structured storage is accessed via CoreData, which is an object-relational mapping and thus strongly schema-based. You can update a CoreData app's schema, but migrating existing data can be tricky. (I have no idea what happens if iCloud tries to sync between two devices that are running two versions of an app that use different schema!) NoSQL databases like TouchDB are a lot more flexible about how data is stored, so this is less of an issue.

Sharing. iCloud only syncs between devices owned by the same person. CouchDB-like systems can do that; or share in small groups (like Glassboard, GroupMe, etc.); or publish to the public (like a blog or Instagram). Hybrids of those are possible too.

Cross-Platform. I'm willing to bet there are iOS users who also have an Android device, or run Linux on their PC. iCloud won't work for that, but TouchDB/CouchDB will. CouchDB even supports web interfaces for maximum portability.

Flexible Storage. iCloud puts everything on Apple's servers. I'm sure these are reliable and secure, but it's good to have choices. TouchDB can sync to hosted services like IrisCouch or Cloudant; to Amazon-hosted server instances; to your own servers; to a desktop machine (the way Things does); or in the future even peer-to-peer once I get the Bonjour bits hooked up.

Enterprise Data. The only way to get data into an iCloud account is from an iOS device or Mac. But a frequent desire in mobile apps is to view small subsets of a huge upstream database (whether enterprise sales data, scientific observations, or consumer info like movie reviews) and be able to work with them while offline or bandwidth-limited. This is exactly what Syncpoint, the client/server system Couchbase is building around TouchDB, will do. Using filtered replication it'll be able to download mobile-sized views of big data.

Flexible Topology. A star is the easiest, with devices all connecting to a single server, but CouchDB-like syncing allows for servers to sync to each other, creating a mesh (whether permanent or ad-hoc.) You could set up home/office servers that devices sync to, which in turn sync to a cloud service.

Open Code & Protocols. Apple's not going to show you iCloud's source code, or even describe the details of the protocols. If you find bugs, you have to wait for Apple to acknowledge and fix them. If you want to write your own client library, good luck reverse-engineering. TouchDB (like all other Couchbase products, and also CouchDB) is open source, and the protocols are REST-based and publicly documented.

Something went wrong with that request. Please try again.