Skip to content
Jens Alfke edited this page Jun 13, 2014 · 25 revisions

Contents

  • What Is This?
  • Performance & Size
  • Compatibility
  • Implementation & Design
  • Choices, Choices
  • Usage issues

What Is This?

Q: What is Couchbase Lite?

A: An ultra-lightweight and flexible mobile database that easily syncs with the cloud, built for all your mobile application needs.

Q: Is it the same thing as TouchDB?

It was originally known as TouchDB. In January 2013 we changed the name to Couchbase Lite to tie it in with Couchbase’s branding. The original 1.0 release of TouchDB has kept the old naming, but the newer releases are known as Couchbase Lite.

Q: What does it run on?

A: The reference Objective-C implementation runs on iOS 6+ and Mac OS X 10.7+. There is also a Java port for Android devices.

The Objective-C implementation was at one point adapted to run in the GNUstep environment, which is portable to Linux, BSD, Solaris, etc. and even Microsoft Windows; but it hasn’t been built or run in that environment for a while, so there would certainly be more work to do to bring it back up to speed.

Q: How mature is it?

A: It’s passed the 1.0 milestone, and the released versions are ready to use in apps. As with any open source project, the latest commits do represent “bleeding-edge” functionality and should be used with caution.

Q: Is there a demo?

A: The simplest is Grocery Sync, which implements a simple checklist that can sync with a server. The ToDo-Lite app is more advanced, featuring multiple lists that can be shared between users. CouchChat is a multi-user chat app.

Q: What’s the license?

A: Couchbase Lite itself is released under the Apache License 2.0

Some libraries that Couchbase Lite uses (FMDB, MYUtilities, and CocoaHTTPServer) have MIT or BSD licenses. We may seek relicensing or rewrite those parts of the code, to get everything under a single (Apache) license.

Q: Who’s behind this?

A: Couchbase

Q: Have any developers shipped apps using Couchbase Lite?

A: Yes; you can see a partial list on the “Couchbase Lite In The Wild” page. A notable example is Hub , a family organizer that was chosen by Apple as a “Best New Productivity App”.

Q: Can I ask more questions?

A: Sure — the Google group is the best place. (You can access it on the web or subscribe to it as a mailing list.)

Performance & Size

Q: How big is Couchbase Lite?

A: Version 1.0 compiles to about 500k bytes of optimized ARM7 code. (The framework you’ll download or build is much larger because it contains a lot of linker metadata, as well as x86 code for the simulator, which don’t get copied into your app.)

Q: How long does it take to start up?

A: About 100ms to initialize the library and open a small database. That’s a cold launch; if the app has been launched and quit recently, leaving stuff in cache, it’s more like 60ms. This is on an iPad 2; older devices will be a bit slower.

Q: How fast is it?

A: Fast enough for the kinds of data sets mobile apps would be expected to use. It’s effectively instantaneous for small data sets. It won’t handle big data as well as Couchbase Server, but it keeps up pretty well with tens or hundreds of thousands of documents. And it doesn’t mind arbitrarily large binary attachments; those are kept as files in the filesystem.

Q: How much data can it handle?

A: There aren’t any hard limits in Couchbase Lite itself, nor to my knowledge in SQLite. The most likely practical limit is the available disk/flash storage on the device, and of course app responsiveness as query times increase (see above).

I’ve heard that Android has a 2GB file size limit; but this should be less of a problem for Couchbase Lite, because the database file doesn’t grow as fast (it doesn’t need explicit compaction) and because it doesn’t store attachments inside the database file.

Compatibility

Q: Is Couchbase Lite compatible with Apache CouchDB?

A: In the ways that matter, yes. The REST API is compatible, although you talk to the engine in-process rather than over a socket. Some of the more server-centric features of CouchDB, like user accounts, aren’t supported.

Q: Can it replicate with Apache CouchDB servers?

A: Yes, its replication protocol is entirely compatible. That’s a very important goal. Apps using Couchbase Lite can sync with servers running Apache CouchDB, as well as with Couchbase Server via Sync Gateway.

Q: Can it replicate with Couchbase Server?

A: The [Sync Gateway](https://github.com/couchbaselabs/sync-gateway) acts as a server-side bridge between Couchbase Server and Couchbase Lite. Once your data is synced to Couchbase Server you can use map reduce to build indexes across the full dataset.

Q: Does it have conflict handling and revision-trees like Apache CouchDB?

A: Yes. Revision trees are implemented, and preserved across replication.

Q: Does it have map/reduce based views?

A: Yes, although for size reasons it doesn’t include a JavaScript interpreter, so views are implemented in native code (e.g. as blocks in Objective-C.) The same goes for filter and validation functions. (It’s possible to use JavaScript-based functions if you’re willing to link in some extra code and libraries.)

Q: Can’t you access Couchbase Lite over HTTP?

A: There’s an experimental HTTP server extension called CouchbaseLiteListener. It’s mostly there to enable Couchbase Lite-to-Couchbase Lite (P2P) replication as well as making testing easier, and to support PhoneGap style HTML5 development.

Q: What about CouchApps?

A: CouchApps running in PhoneGap are definitely an interesting mobile platform. We have a PhoneGap plugin showing how to combine Couchbase Lite with PhoneGap. Most CouchApps should be able to run with only minor modifications.

Q: Why SQLite instead of a B-tree engine like Berkeley DB or Kyoto Cabinet?

A: Largely because SQLite is already available as a shared library on every platform we’re interested in; this keeps our code size down and simplifies the build process.

Additionally, both Berkeley and Kyoto have GPL-like licenses that are less friendly to commercial developers (especially iOS developers) and incompatible with the Apache license of Couchbase Lite itself.

Choices, Choices

Q: Why would I use this instead of earlier generations of Couchbase technology for mobile?

A: Because it’s a lot smaller, starts up a lot more quickly, and is easily embeddable into an app. Those are important factors for mobile app developers (and some desktop app developers too.) If you’re working on server-side software they probably don’t matter to you, or at least don’t outweigh the drawbacks.

Q: Why would I use this instead of iOS’s CoreData framework?

A: World-class, highly-flexible data sync capabilities that go way beyond what you can get from iCloud. Another factor is that the API is (we think) simpler and easier to use than CoreData’s.

Q: Why would I use this instead of working directly with SQLite (or an adapter like FMDB)?

A: As with the previous comparison to CoreData: the big reason is sync. If your users want to work with their data on multiple devices or platforms (including the Web), or have it transparently backed up, the replication capabilities in Couchbase Lite will make it very easy compared to the pain of implementing sync yourself, or trying to duct-tape your custom SQLite database to the iCloud APIs.

Usage Issues

Q: How do I cancel a persistent, continuous replication?

A: Delete the CBLReplication model:

[repl deleteDocument: &error];

Alternatively, you can do:
[db replicateWithURL: nil exclusively: YES];

which will delete all replications involving that database.
Clone this wiki locally