apache couchdb

Post on 25-May-2015

170 Views

Category:

Education

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

Apache CouchDB

Course: Advanced DatabasesGroup 5: Trinh Phuc Tho, Vo Quoc Khanh, Hoang Trung Hieu

1

What to expect?

Technical Overview

Consistency Model

Live Demo

2

Technical Overview

Document Storage

ACID Properties

Compaction

Views

Distributed Updates

Conflict Resolution

3

Technical Overview

So, wtf is CouchDB?

NoSQL databases

document store

distributed architecture

easy replication

4

Technical Overview

Document Storage

use append-only files

documents stored as JSON

access via RESTful HTTP API

map-reduce functions (Javascript) for views

5

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

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

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 chunksto make up the first 4 KB of the file

Handling failures:Case 1: Partially flushed updates are simply ignoredCase 2: The surviving copy is used

8

Technical Overview

ACID Properties (3)

9

Technical Overview

Compaction

data cloned to a new file

redundant data are removed

no downtime required

10

Technical Overview

Views

allow aggregating and reporting on documents

use Javascript map-reduce functions

view indexes are built only once and updated incrementally

11

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

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

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

Consistency Model

The CAP theorem

Local Consistency

Validation

15

Consistency Model

The CAP Theorem

16

Consistency Model

Local Consistency

No Locking

17

Consistency Model

Validation

Javascript functions are used for validation Context information is provided Updates can be approved or denied

18

Live Demo

CRUD

Views

19

References

Apache CouchDB 1.6 documentationhttp://docs.couchdb.org/en/1.6.x/

Karel Minařík presentation at WebExpo2010http://webexpo.net/prague2010/talk/couchdb-database-for-the-web/

Introduction to REST & CouchDB, ULM Universityhttp://www.slideshare.net/partlycloudy/introduction-to-rest-couchdb

20

top related