why couchdb is cool

34
Webtechcon Milano 10/11/2010

Upload: gabriele-lana

Post on 15-Jan-2015

2.304 views

Category:

Technology


2 download

DESCRIPTION

A short presentation (25') focused on why I think couchdb is cool, what he does really well and for what problems he should be used to solve

TRANSCRIPT

Page 1: Why couchdb is cool

Webtechcon Milano 10/11/2010

Page 2: Why couchdb is cool

gabriele [email protected]

twitter: @gabrielelana

Page 3: Why couchdb is cool

“i can’t tell you how i work in 25’ but i can

tell you why i am cool”

Page 4: Why couchdb is cool

what i am #1

documentorienteddatabase

Page 5: Why couchdb is cool

key -> document

name: “Gabriele”job: “Programmer”born: “02/07/1977”

company: “CleanCode”

1

name: “Paolo”job: “Manager”

born: “17/12/1965”company: “BadCode”

2

name: “Enzo”job: “Plumber”

born: “22/04/1982”company: “CleanPipe”

3

Page 6: Why couchdb is cool

complex values

name: “Gabriele”job: “Programmer”

born: [ 2, 7, 1977 ]company: “CleanCode”

1

Page 7: Why couchdb is cool

map as filter

function(document){if(document.job==="Programmer"){emit(document.id,document)}}

...1

...2

...3

...1

...2

...3

Page 8: Why couchdb is cool

map as filter

function(document){if(document.job==="Programmer"){emit(document.id,document)}}

yep is javascript

Page 9: Why couchdb is cool

map -> index

function(document){emit(document.born,document)}

...19651217

...19970702

...19820422

Page 10: Why couchdb is cool

range queries are fast

function(document){emit(document.born,document)}

...19651217

...19970702

...19820422

Page 11: Why couchdb is cool

map -> reduce -> index

from: “Gabriele”to: “Chiara”

at: [2010,11,11,21,30] message: “...”

1

How many messagessended from gabriele?

Page 12: Why couchdb is cool

map -> reduce -> index

function(document){emit(document.from,1)}

function(from,messages){sum(messages)}

127“Chiara”

10“Gabriele”

45“Renato”

Page 13: Why couchdb is cool

index with complex key

function(document){emit([document.from].concat(document.at)),1)}

1[ “Gabriele”,2010,11,11,21,30 ]

Page 14: Why couchdb is cool

reduce by group levels

1[ “Gabriele”,2010,11,11,21,30 ]

4[ “Gabriele”,2010,11 ]

7[ “Gabriele”,2010 ]

10[ “Gabriele” ]

level 3

level 2

level 1

Page 15: Why couchdb is cool

logarithmic update

map/reduce

Page 16: Why couchdb is cool

logarithmic update

map/reduce

Page 17: Why couchdb is cool

logarithmic update(real time queries)

map/reduce

Page 18: Why couchdb is cool

crash only policy

appendonly

rev/0 rev/1multiversionconcurrency

control

Page 19: Why couchdb is cool

replication

• master -> slave

Page 20: Why couchdb is cool

replication

• master -> slave• master -> slaves

Page 21: Why couchdb is cool

replication

• master -> slave• master -> slaves• master -> master

Page 22: Why couchdb is cool

replication

• master -> slave• master -> slaves• master -> master• PEEr -> peer

Page 23: Why couchdb is cool

sharding

Page 24: Why couchdb is cool

usage patterns

oltp olapRelatively

standardized and simple queries

Returning relatively few

records

Often complex queries involving

aggregations.Periodic batch

jobs refresh the data

Page 25: Why couchdb is cool

what i am #2

webserver

Page 26: Why couchdb is cool

web server

http

• crud on documents• documents attachments• long polling changes• proper caching• lots of libraries• firewall friendly

Page 27: Why couchdb is cool

what i am #3

applicationserver

Page 28: Why couchdb is cool

application server

Page 29: Why couchdb is cool

application server

Page 30: Why couchdb is cool

application server

• show document• list documents• authentication• url rewrite• good for small applications• good for back offices

Page 31: Why couchdb is cool

i have good friends

Page 32: Why couchdb is cool

books...

Page 33: Why couchdb is cool

questions?

Page 34: Why couchdb is cool

gabriele [email protected]

twitter: @gabrielelana