Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Apache CouchDB

1,310 views

Published on

The presentation provided by my study group on the Advanced DB course at FPT University, HCMC, Vietnam.

Published in: Education
  • Be the first to comment

  • Be the first to like this

Apache CouchDB

  1. 1. Apache CouchDB Course: Advanced Databases Group 5: Trinh Phuc Tho, Vo Quoc Khanh, Hoang Trung Hieu 1
  2. 2. What to expect?  Technical Overview  Consistency Model  Live Demo 2
  3. 3. Technical Overview  Document Storage  ACID Properties  Compaction  Views  Distributed Updates  Conflict Resolution 3
  4. 4. Technical Overview So, wtf is CouchDB?  NoSQL databases  document store  distributed architecture  easy replication 4
  5. 5. Technical Overview Document Storage  use append-only files  documents stored as JSON  access via RESTful HTTP API  map-reduce functions (Javascript) for views 5
  6. 6. Technical Overview ACID Properties  commitment system features all ACID properties  never overwrite committed data (append-only)  no shutdown process  no “repair” command needed (Clap!!!) 6
  7. 7. Technical Overview ACID Properties (2)  document updates are serialized  readers never have to wait on writers, even on the same document  Multi-version Concurrency Control (MVCC)  additional sequence IDs (_rev) are used 7
  8. 8. Technical Overview ACID Properties (3)  2-step commit: Step 1: Document data & associated index updates are flushed to disk (append to file). Step 2: The updated database header is written in two consecutive, identical chunks to make up the first 4 KB of the file  Handling failures: Case 1: Partially flushed updates are simply ignored Case 2: The surviving copy is used 8
  9. 9. Technical Overview ACID Properties (3) 9
  10. 10. Technical Overview Compaction  data cloned to a new file  redundant data are removed  no downtime required 10
  11. 11. Technical Overview Views  allow aggregating and reporting on documents  use Javascript map-reduce functions  view indexes are built only once and updated incrementally 11
  12. 12. Technical Overview Distributed Updates  Peer-based distributed database system  Incremental replication (partial replication is allowed)  Peers access & update the same data while disconnected  need for conflict resolution after replication 12
  13. 13. Technical Overview Conflict Resolution  allow for decentralized conflict resolution  preserve single document semantics  conflicting documents are also replicated  after replication, one revision will be picked as the “winner” by a deterministic algorithm so that the same choice will be made on all peers  other revisions are marked as _deleted, and will not be removed during compaction. 13
  14. 14. Technical Overview Conflict Resolution (2)  Get conflicting revisions: GET /db/doc_id?conflicts=true  Fetch a history revision: GET /db/doc_id?rev=xxxx 14
  15. 15. Consistency Model  The CAP theorem  Local Consistency  Validation 15
  16. 16. Consistency Model The CAP Theorem 16
  17. 17. Consistency Model Local Consistency  No Locking 17
  18. 18. Consistency Model Validation  Javascript functions are used for validation  Context information is provided  Updates can be approved or denied 18
  19. 19. Live Demo  CRUD  Views 19
  20. 20. References  Apache CouchDB 1.6 documentation http://docs.couchdb.org/en/1.6.x/  Karel Minařík presentation at WebExpo2010 http://webexpo.net/prague2010/talk/couchdb-database-for-the-web/  Introduction to REST & CouchDB, ULM University http://www.slideshare.net/partlycloudy/introduction-to-rest-couchdb 20

×