why couchdb is cool
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 solveTRANSCRIPT
Webtechcon Milano 10/11/2010
gabriele [email protected]
twitter: @gabrielelana
“i can’t tell you how i work in 25’ but i can
tell you why i am cool”
what i am #1
documentorienteddatabase
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
complex values
name: “Gabriele”job: “Programmer”
born: [ 2, 7, 1977 ]company: “CleanCode”
1
map as filter
function(document){if(document.job==="Programmer"){emit(document.id,document)}}
...1
...2
...3
...1
...2
...3
map as filter
function(document){if(document.job==="Programmer"){emit(document.id,document)}}
yep is javascript
map -> index
function(document){emit(document.born,document)}
...19651217
...19970702
...19820422
range queries are fast
function(document){emit(document.born,document)}
...19651217
...19970702
...19820422
map -> reduce -> index
from: “Gabriele”to: “Chiara”
at: [2010,11,11,21,30] message: “...”
1
How many messagessended from gabriele?
map -> reduce -> index
function(document){emit(document.from,1)}
function(from,messages){sum(messages)}
127“Chiara”
10“Gabriele”
45“Renato”
index with complex key
function(document){emit([document.from].concat(document.at)),1)}
1[ “Gabriele”,2010,11,11,21,30 ]
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
logarithmic update
map/reduce
logarithmic update
map/reduce
logarithmic update(real time queries)
map/reduce
crash only policy
appendonly
rev/0 rev/1multiversionconcurrency
control
replication
• master -> slave
replication
• master -> slave• master -> slaves
replication
• master -> slave• master -> slaves• master -> master
replication
• master -> slave• master -> slaves• master -> master• PEEr -> peer
sharding
usage patterns
oltp olapRelatively
standardized and simple queries
Returning relatively few
records
Often complex queries involving
aggregations.Periodic batch
jobs refresh the data
what i am #2
webserver
web server
http
• crud on documents• documents attachments• long polling changes• proper caching• lots of libraries• firewall friendly
what i am #3
applicationserver
application server
application server
application server
• show document• list documents• authentication• url rewrite• good for small applications• good for back offices
i have good friends
books...
questions?
gabriele [email protected]
twitter: @gabrielelana