Mihai Plesa - CouchDB

24
CouchDB

description

 

Transcript of Mihai Plesa - CouchDB

Page 1: Mihai Plesa - CouchDB

CouchDB

Page 2: Mihai Plesa - CouchDB

[email protected] ~$ whoami

Page 3: Mihai Plesa - CouchDB

ls -l /couchdb/

● intro● demo

Page 4: Mihai Plesa - CouchDB

view /couchdb/lol

Page 5: Mihai Plesa - CouchDB

head /couchdb/about

Apache CouchDB is a document-oriented database that can be queried and indexed using

JavaScript in a MapReduce fashion.

CouchDB also offers incremental replication with bi-directional conflict detection and resolution.

Page 6: Mihai Plesa - CouchDB

cat /couchdb/about

CouchDB provides a RESTful JSON API than can be accessed from any environment that allows

HTTP requests.

CouchDB’s built in Web admin console speaks directly to the database using HTTP requests

issued from your browser.

Page 7: Mihai Plesa - CouchDB

tail /couchdb/about

CouchDB is written in Erlang, a robust functional programming language ideal for building

concurrent distributed systems.

Erlang allows for a flexible design that is easily scalable and readily extensible.

Page 8: Mihai Plesa - CouchDB

cat /couchdb/history

started in 2005 by Damien Katz

became an Apache project in 2008

currently at version 1.1.1

Page 9: Mihai Plesa - CouchDB

head /couchdb/how

CouchDB is a document oriented database

data is stored in “documents” and not in “relations” like in an RDBMS

non-locking MVCC and ACID compliant data store

Page 10: Mihai Plesa - CouchDB

view /couchdb/how

Page 11: Mihai Plesa - CouchDB

view /couchdb/how

Page 12: Mihai Plesa - CouchDB

cat /couchdb/how

no SQL

querying is done using “views”

views are defined using Map/Reduce functions

data is indexed using these views as it is stored in the DB

Page 13: Mihai Plesa - CouchDB

cat /couchdb/how

Map functions emit (key, value) interpretation of the data

Reduce functions aggregate data emitted by map functions

Map/Reduce functions are written in JavaScript or CoffeeScript

Page 14: Mihai Plesa - CouchDB

head /couchdb/use

good for:

storing documents – or any data which is document-like

hosting entire applications

Page 15: Mihai Plesa - CouchDB

cat /couchdb/why

very easy to program with – no SQL, no schema, no ORM

schema-less means very easy to deploy changes

easy to administer, backup, replicate, can work offline

Page 16: Mihai Plesa - CouchDB

tail /couchdb/use

not suitable for:

storing data which is relational in nature

be careful with data that needs to have unique values

Page 17: Mihai Plesa - CouchDB

view /couchdb/lol

Page 18: Mihai Plesa - CouchDB

vi /couchdb/doc

{

“_id”: ”BCCD12CBB”,

“_rev”: ”AB764C”,

“type”: ”person”,

“name”: ”Darth Vader”,

“age”: 63,

“headware”:

[“Helmet”, “Sombrero”],

“dark_side”: true

}

Page 19: Mihai Plesa - CouchDB

cat /couchdb/rest/how

create: HTTP POST /db/BCCD12CBB

read: HTTP GET /db/BCCD12CBB

update: HTTP PUT /db/BCCD12CBB

delete: HTTP DELETE /db/BCCD12CBB

Page 20: Mihai Plesa - CouchDB

head /couchdb/rest/usage

$ curl -X GET http://server/database/document

{“_id”:”ABC”,“_rev”:”1D4”,”data”:...}

Page 21: Mihai Plesa - CouchDB

cat /couchdb/tests

silly read-only benchmark with memory saturation

2,500 req/s sustained on a 2Ghz dual core Athlon

using 9.8 mb RAM

Page 22: Mihai Plesa - CouchDB

exec /couchdb/demo

let's get dirty!

Page 23: Mihai Plesa - CouchDB

view /couchdb/lol

Page 24: Mihai Plesa - CouchDB

sudo halt

Q?