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
![Page 1: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/1.jpg)
Webtechcon Milano 10/11/2010
![Page 3: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/3.jpg)
“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](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/4.jpg)
what i am #1
documentorienteddatabase
![Page 5: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/5.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/6.jpg)
complex values
name: “Gabriele”job: “Programmer”
born: [ 2, 7, 1977 ]company: “CleanCode”
1
![Page 7: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/7.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/8.jpg)
map as filter
function(document){if(document.job==="Programmer"){emit(document.id,document)}}
yep is javascript
![Page 9: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/9.jpg)
map -> index
function(document){emit(document.born,document)}
...19651217
...19970702
...19820422
![Page 10: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/10.jpg)
range queries are fast
function(document){emit(document.born,document)}
...19651217
...19970702
...19820422
![Page 11: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/11.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/12.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/13.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/14.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/15.jpg)
logarithmic update
map/reduce
![Page 16: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/16.jpg)
logarithmic update
map/reduce
![Page 17: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/17.jpg)
logarithmic update(real time queries)
map/reduce
![Page 18: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/18.jpg)
crash only policy
appendonly
rev/0 rev/1multiversionconcurrency
control
![Page 19: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/19.jpg)
replication
• master -> slave
![Page 20: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/20.jpg)
replication
• master -> slave• master -> slaves
![Page 21: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/21.jpg)
replication
• master -> slave• master -> slaves• master -> master
![Page 22: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/22.jpg)
replication
• master -> slave• master -> slaves• master -> master• PEEr -> peer
![Page 23: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/23.jpg)
sharding
![Page 24: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/24.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/25.jpg)
what i am #2
webserver
![Page 26: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/26.jpg)
web server
http
• crud on documents• documents attachments• long polling changes• proper caching• lots of libraries• firewall friendly
![Page 27: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/27.jpg)
what i am #3
applicationserver
![Page 28: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/28.jpg)
application server
![Page 29: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/29.jpg)
application server
![Page 30: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/30.jpg)
application server
• show document• list documents• authentication• url rewrite• good for small applications• good for back offices
![Page 31: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/31.jpg)
i have good friends
![Page 32: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/32.jpg)
books...
![Page 33: Why couchdb is cool](https://reader034.vdocuments.net/reader034/viewer/2022051818/54b790414a7959d7418b464c/html5/thumbnails/33.jpg)
questions?