In my last article I spoke about MongoDB, one of the most popular NoSQL databases so I’ll make a presentation of CouchDB, another great NoSQL database that has some amazing features and how it compares to MongoDB and CouchBase.
CouchDB is written in Erlang, a computer language highly optimized for concurrency, distribution and fault tolerance. Beside being fast from the name and logo we can have a hint that the database was targeted for easy use. Their focus was to increase developers's productivity by having easy to use tools.
A document is a JSON object, very easy to integrate with web applications where JSON is the most used format. A flat collection of these documents is a couchdb database and each document is identified by a key ID. Each document has also a revision number (_rev) for each change in the document.
Built-in HTTP REST API:
All the documents can be accesed directly from the web with a builtin REST API, without the need of special drivers. Beside accessed, all the usual operations can be performed with this API: insertion, updates, retrieval and deletion. This means that database can perform operations directly from clients without the need of a backend.
Similar to MongoDB there is no fixed schema in CouchDB. All the data can be stored semi-structured and it is also document oriented. This gives the developer a lot of flexibility and simplifies the process of building document oriented applications like collaborative applications.
Technically CouchDB is a peer based distributed database system. Even mobile phones can have independent copies of the data and applications can perform all operations on that data. So a CouchDB host can be any type of client, online or offline.
Using the built-in conflict detection and management, replication can be very fast and reliareble. One interesting feature is master-master replication, making multi-site applications very easy to deploy.
Regular RDBS like MySQL and as well NoSQL databases use locking to make sure that a table or row is not modified in the same time by another client. Instead CouchDB uses a concept called MVCC (Multi Version Concurrency Control). In the above figure you can see the difference between locking and MVCC, basically reads don’t wait for a table to be unlocked where the table is edited. This means that under heavy load the system will use the resources better
Eventual consistency offers the ability to provide partition tolerance and availability.
Couchbase was started by Damien Katz, who originally created CouchDB.
Couchbase is a merge between CouchDB and Membase to create an easily scalable and high performance database.
- has a memcached-based caching technology;
- has built-in clustering system and data is automatically spread across multiple nodes, this feature is called auto-sharding;
- automatic fail-over of nodes;
- HTTP API is not available on CouchBase.
Considering the key differences, CouchBase is more suited for realtime database access.
CouchDB has some advantages over MongoDB with features like:
- multi master replication which is very helpful when two databases are located in two different datancenters;
- built-in HTTP REST API;
- no database locking, thanks to MVCC.
In the same time some great features from MongoDB are not supported in CouchDB:
- auto sharding which make very easy to scale write operations;
- automatic failover of nodes.
- built-in full text search
- monitoring service like MMS
More about MongoDB can be found on our MongoDB Overview.
Do you want to build a new CMS or CRM application from the ground up while using a highly available and reliable database? Look no further, CouchDB is perfect for this kind of application. Its multi-master feature makes databases very easy to deploy in multiple datacenters.
Need us to develop your next app?
Update: Please take a look at my last blog posts: Cloud offering: Comparison between IaaS, PaaS, SaaS, BaaS