Jump to content

Apache CouchDB

From Wikipedia, the free encyclopedia
Apache CouchDB
Original author(s)Damien Katz, Jan Lehnardt, Naomi Slater, Christopher Lenz, J. Chris Anderson, Paul Davis, Adam Kocoloski, Jason Davies, Benoît Chesneau, Filipe Manana, Robert Newson
Developer(s)Apache Software Foundation
Initial release2005;19 years ago(2005)
Stable release
3.3.3[1]Edit this on Wikidata / 4 December 2023;7 months ago(4 December 2023)
Repository
Written inErlang,JavaScript,C,C++
Operating systemCross-platform
TypeDocument-oriented database
LicenseApache License 2.0
Websitecouchdb.apache.orgEdit this on Wikidata

Apache CouchDBis anopen-sourcedocument-orientedNoSQLdatabase, implemented inErlang.

CouchDB uses multiple formats and protocols to store, transfer, and process its data. It usesJSONto store data,JavaScriptas its query language usingMapReduce,andHTTPfor anAPI.[2]

CouchDB was first released in 2005 and later became anApache Software Foundationproject in 2008.

Unlike arelational database,a CouchDB database does not store data and relationships in tables. Instead, each database is a collection of independent documents. Each document maintains its own data and self-contained schema. An application may access multiple databases, such as one stored on a user's mobile phone and another on a server. Document metadata contains revision information, making it possible to merge any differences that may have occurred while the databases were disconnected.

CouchDB implements a form ofmultiversion concurrency control(MVCC) so it does not lock the database file during writes. Conflicts are left to the application to resolve. Resolving a conflict generally involves first merging data into one of the documents, then deleting the stale one.[3]

Other features include document-levelACIDsemantics witheventual consistency,(incremental) MapReduce, and (incremental) replication. One of CouchDB's distinguishing features ismulti-master replication,which allows it to scale across machines to build high-performance systems. A built-in Web application called Fauxton (formerly Futon) helps with administration.

History[edit]

Couchis an acronym forcluster of unreliable commodity hardware.[4] The CouchDB project was created in April 2005 by Damien Katz, a formerLotus Notesdeveloper atIBM.He self-funded the project for almost two years and released it as an open-source project under theGNU General Public License.

In February 2008, it became an Apache Incubator project and was offered under theApache Licenseinstead.[5]A few months after, it graduated to a top-level project.[6]This led to the first stable version being released in July 2010.[7]

In early 2012, Katz left the project to focus onCouchbase Server.[8]

Since Katz's departure, the Apache CouchDB project has continued, releasing 1.2 in April 2012 and 1.3 in April 2013. In July 2013, the CouchDB community merged the codebase forBigCouch,Cloudant's clustered version of CouchDB, into the Apache project.[9]The BigCouch clustering framework is included in the current release of Apache CouchDB.[10]

Native clustering is supported at version 2.0.0. And the new Mango Query Server provides a simple JSON-based way to perform CouchDB queries without JavaScript or MapReduce.

Main features[edit]

ACID Semantics
CouchDB providesACIDsemantics.[11]It does this by implementing a form ofMulti-Version Concurrency Control,meaning that CouchDB can handle a high volume of concurrent readers and writers without conflict.
Built for Offline
CouchDB can replicate to devices (like smartphones) that can go offline and handle data sync for you when the device is back online.
Distributed Architecture with Replication
CouchDB was designed with bi-directional replication (or synchronization) and off-line operation in mind. That means multiple replicas can have their own copies of the same data, modify it, and then sync those changes at a later time.
Document Storage
CouchDB stores data as "documents", as one or more field/value pairs expressed asJSON.Field values can be simple things like strings, numbers, or dates; butordered listsandassociative arrayscan also be used. Every document in a CouchDB database has a unique id and there is no required document schema.
Eventual Consistency
CouchDB guaranteeseventual consistencyto be able to provide both availability and partition tolerance.
Map/Reduce Views and Indexes
The stored data is structured using views. In CouchDB, each view is constructed by aJavaScriptfunction that acts as the Map half of amap/reduce operation. The function takes a document and transforms it into a single value that it returns. CouchDB can index views and keep those indexes updated as documents are added, removed, or updated.
HTTP API
All items have a unique URI that gets exposed via HTTP. It uses theHTTP methodsPOST, GET, PUT and DELETE for the four basicCRUD(Create, Read, Update, Delete) operations on all resources.

CouchDB also offers a built-in administration interface accessible via Web called Fauxton.[12]

Use cases and production deployments[edit]

Replication and synchronization capabilities of CouchDB make it ideal for using it in mobile devices, where network connection is not guaranteed, and the application must keep on working offline.

CouchDB is well suited for applications with accumulating, occasionally changing data, on which pre-defined queries are to be run and where versioning is important (CRM, CMS systems, by example). Master-master replication is an especially interesting feature, allowing easy multi-site deployments.[13]

Users[edit]

Users of CouchDB include:

  • CERNuses CouchDB as database for the Data Management System at theLarge Hadron Collider.[14]
  • Red Crossuse the application iDAT for completing casework electronically in disaster areas. Here CouchDB is used as multi-node peer-to-peer offline-first database.[15]
  • IBMCloud services are based at a fundamental level on CouchDB.[16]
  • United Airlinesuses CouchDB for the in-flight entertainment systems in over 3,000 planes.[17][18]
  • Amadeus IT Group,for some of their back-end systems.[citation needed]
  • Credit Suisse,for internal use at commodities department for their marketplace framework.[19][better source needed]
  • Meebo,for their social platform (Web and applications).[citation needed]Meebo was acquired by Google and most products were shut down on July 12, 2012.[20]
  • npmuses CouchDB as replicating database for their package registry.[21]
  • Sophos,for some of their back-end systems.[citation needed]
  • BBC,for a dynamic CMS-Platform.[22]
  • Canonicalbegan using it in 2009 for its synchronization service "Ubuntu One",[23]but stopped using it in November 2011.[24]
  • CANAL+for international on-demand platform at CANAL+ Overseas.
  • Protogrid,as storage back-end for their rapid application development framework[25]

Data manipulation: documents and views[edit]

CouchDB manages a collection ofJSONdocuments. The documents are organised via views. Views are defined withaggregate functionsand filters are computed in parallel, much likeMapReduce.

Views are generally stored in the database and their indexes are updated continuously. CouchDB supports a view system using external socket servers and a JSON-based protocol.[26]As a consequence, view servers have been developed in a variety of languages (JavaScript is the default, but there are also PHP, Ruby, Python and Erlang).

Accessing data via HTTP[edit]

Applications interact with CouchDB via HTTP. The following demonstrates a few examples usingcURL,a command-line utility. These examples assume that CouchDB is running onlocalhost(127.0.0.1) on port 5984.

Action Request Response
Accessing server information
curlhttp://127.0.0.1:5984/
{
"couchdb":"Welcome",
"version":"1.1.0"
}
Creating a database namedwiki
curl-XPUThttp://127.0.0.1:5984/wiki
{"ok":true}
Attempting to create a second database namedwiki
curl-XPUThttp://127.0.0.1:5984/wiki
{
"error":"file_exists",
"reason":"The database could not be created, the file already exists."
}
Retrieve information about thewikidatabase
curlhttp://127.0.0.1:5984/wiki
{
"db_name":"wiki",
"doc_count":0,
"doc_del_count":0,
"update_seq":0,
"purge_seq":0,
"compact_running":false,
"disk_size":79,
"instance_start_time":"1272453873691070",
"disk_format_version":5
}
Delete the databasewiki
curl-XDELETEhttp://127.0.0.1:5984/wiki
{"ok":true}
Create a document, asking CouchDB to supply a document id
curl-XPOST-H"Content-Type: application/json"--data\
'{ "text": "Wikipedia on CouchDB", "rating": 5 }'\
http://127.0.0.1:5984/wiki
{
"ok":true,
"id":"123BAC",
"rev":"946B7D1C"
}
get a list of databases
curlhttp://127.0.0.1:5984/_all_dbs
["_replicator","_users","wiki"]

Open source components[edit]

CouchDB includes a number of other open source projects as part of its default package.

Component Description License
Erlang Erlang is a general-purposeconcurrentprogramming languageandruntimesystem. The sequential subset of Erlang is afunctional languagewithstrict evaluation,single assignment,anddynamic typing Apache 2.0(Release 18.0 and later)
Erlang Public License(Earlier releases)
ICU International Components for Unicode (ICU) is anopen-sourceproject of matureC/C++andJavalibraries forUnicodesupport, softwareinternationalizationand software globalization Unicode License
jQuery jQuery is a lightweightcross-browserJavaScript librarythat emphasizes interaction betweenJavaScriptandHTML MIT License
OpenSSL OpenSSL is anopen-sourceimplementation of theSSL and TLSprotocols. The corelibrary(written in theC programming language) implements the basiccryptographicfunctions and provides various utility functions Apache 1.0and thefour-clause BSD License
SpiderMonkey SpiderMonkey is a performantJavaScript enginemaintained by theMozilla Foundation.It contains aninterpreter,aJIT compilerand agarbage collector MPL 2.0

See also[edit]

References[edit]

  1. ^"Release 3.3.3".4 December 2023.Retrieved19 December2023.
  2. ^Apache Software Foundation."Apache CouchDB".Retrieved15 April2012.
  3. ^Smith, Jason."What is the CouchDB replication protocol? Is it like Git?".StackOverflow.Stack Exchange.Retrieved14 April2012.
  4. ^"Exploring CouchDB".Developer Works.IBM. March 31, 2009.RetrievedSeptember 30,2016.
  5. ^Apache mailing list announcementon mail-archives.apache.org
  6. ^Re: Proposed Resolution: Establish CouchDB TLPon mail-archives.apache.org
  7. ^"CouchDB NoSQL Database Ready for Production Use"Archived2010-11-15 at theWayback Machine,article from PC World of July 2010
  8. ^Katz, Damien."The future of CouchDB".Retrieved15 April2012.
  9. ^Slater, Noah (25 July 2013)."Welcome BigCouch".Retrieved25 July2013.
  10. ^"'2.0'".20 September 2016.Retrieved13 January2017.
  11. ^CouchDB, Technical OverviewArchivedOctober 20, 2011, at theWayback Machine
  12. ^"couchdb-fauxton".GitHub.apache.Retrieved2 May2023.
  13. ^Cassandra vs MongoDB vs CouchDB vs Redis vs Riak vs HBase comparisonfrom Kristóf Kovács
  14. ^"Why Large Hadron Collider Scientists are Using CouchDB".ReadWrite.2010-08-26.Retrieved2022-03-29.
  15. ^iDAT,Red Cross Code, 2021-07-31,retrieved2022-03-29
  16. ^"Database-Deep-Dives-CouchDB".ibm.19 July 2019.Retrieved2022-03-29.
  17. ^"Database-Deep-Dives-CouchDB".ibm.19 July 2019.Retrieved2022-03-29.
  18. ^"United Airlines Streamlines Operations With Couchbase | Case Study".couchbase.Retrieved2022-03-29.
  19. ^"CouchDB in the wild"Archived2017-07-20 at theWayback Machinearticle of the product's Web, a list of software projects and websites using CouchDB
  20. ^Cutler, Kim-Mai (9 June 2012)."Meebo Gets The Classic Google Acq-hire Treatment: Most Products To Shut Down Soon".TechCrunch.AOL Inc.Retrieved7 January2016.
  21. ^"npm-registry-couchapp".GitHub.npm. 17 June 2015.Retrieved7 January2016.
  22. ^CouchDB at the BBC as a fault tolerant, scalable, multi-data center key-value store
  23. ^Email from Elliot Murphy (Canonical)Archived2011-05-05 at theWayback Machineto the CouchDB-Devel list
  24. ^Canonical Drops CouchDB From Ubuntu One (Slashdot)
  25. ^"Protogrid - Über uns".
  26. ^View Server DocumentationArchived2008-10-20 at theWayback Machineon wiki.apache.org

Bibliography[edit]

External links[edit]