why couchdb?
DESCRIPTION
http://www.infoq.com/presentations/Why-CouchDBTRANSCRIPT
![Page 1: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/1.jpg)
Why CouchDB?
![Page 2: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/2.jpg)
builtaka rebuilding on
contribute to
hack at
work at
![Page 3: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/3.jpg)
So...
Why CouchDB?
![Page 4: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/4.jpg)
because...
Data is Lonely
![Page 5: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/5.jpg)
Lonely Data?
data access depends on (often API-less) app (esp. desktop)
web apps are a little better, but not always
API’s are not general meant for replication/backup
app may be open source, but data’s still tangled up (RDBMS)
![Page 6: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/6.jpg)
Enter...
![Page 7: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/7.jpg)
Time to Relax.
![Page 8: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/8.jpg)
Meet CouchDB
coSQL Document Storage Database
JSON Documents + attachments
HTTP/REST (you already know the API)
Map/Reduce Views
Portable Standalone Applications
Replication for Freedom
![Page 9: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/9.jpg)
JSON Documents
Your programming language supports JSON!Adapt data as your application changes.
{“json”: “key/value pairs”, “_id” : “some uuid”, “_rev”: “mvcc key”, “string keys”:
[1,2,3,”four”,null], “schema free”: “flexible”}
![Page 10: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/10.jpg)
Attachments
text/html
image/png
application/ogg
application/pdf
text/javascript
text/css
etc...
![Page 11: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/11.jpg)
HTTP / RESTyou already know the API
GET read
PUT create or update
DELETE delete
POST bulk operation
![Page 12: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/12.jpg)
Map/Reduce Views
![Page 13: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/13.jpg)
Some sample docs
{“docs”:[ {“user”: “Chris”, “points”: 3}, {“user”: “Joe”, “points”: 10}, {“user”: “Alice”, “points”: 5}, {“user”: “Mary”, “points”: 9}, {“user”: “Bob”, “points”: 7}, {“user”: ”Alice”, “points”: 3}]}
![Page 14: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/14.jpg)
Map functionfunction(doc) { if (doc.user && doc.points) { emit(doc.user, doc.points); }}
// output{“rows”:[ {“key”: “Chris”, “value”: 3}, {“key”: “Joe”, “value”: 10}, {“key”: “Alice”, “value”: 5}, {“key”: “Mary”, “value”: 9}, {“key”: “Bob”, “value”: 7}, {“key”: ”Alice”, ”value”: 3}]}
![Page 15: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/15.jpg)
Reduce functionfunction(keys, values, rereduce) { return sum(values);}
// output{"key":null,"value":37}
// output (?group=true){"rows":[ {"key":"Alice","value": 8}, {"key":"Bob", "value": 7}, {"key":"Chris","value": 3}, {"key":"Joe", "value": 10}, {"key":"Mary", "value": 9}]}
![Page 16: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/16.jpg)
Built-in Reducers
_sum
_count
_stat
massively faster than JS reducers
![Page 17: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/17.jpg)
Map/Reduce Queriesin CouchDB...
run over every document in the db
are views that create indexes
use keys and view collation for lookups
can do simple JOINs (?include_docs=true)
are typically written in JS
but can also be written in Erlang, Ruby, Python, and other languages
![Page 18: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/18.jpg)
Portable, Standalone,Applications
CouchApps live inside CouchDB
application server style features in addition to map/reduce views:
_rewrite - URL rewriting
_show - output rendering
_list - output rendering of views
_update - document validation
.js, .css, .png - AJAX app assets
![Page 19: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/19.jpg)
Replication for Freedomtriggered, incremental, filtered,
peer-based, interruptible, fabulous
![Page 20: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/20.jpg)
Replication
append-only file format - MVCC
stateless HTTP API
“built of the Web” - Jacob Kaplan-Moss (of Django fame)
n-master replication
filterable with JS functions
can run continuous (on change)
![Page 21: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/21.jpg)
so...
Why CouchDB?because it replicates!!
![Page 22: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/22.jpg)
Web 2.5?
![Page 23: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/23.jpg)
Web 2.0 Gave Us...
Cloud Powers!!1!
data-center sized processing & storage for all my junk
Crowd Powers
sharing stuff with everybody, all the time from anywhere, hurray
![Page 24: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/24.jpg)
for that, we traded
ownership
privacy
security
safety
stability
sanity...?
![Page 25: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/25.jpg)
Next, we need...
those things back
![Page 26: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/26.jpg)
to get that, we needreplication
(saw that coming, probably)
closer data
closer apps
without the loss of our Cloud & Crowd Powers
big data storage & processing (as needed)
sharing with the world (as needed)
or via peer-based replication
![Page 27: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/27.jpg)
Hop on CouchDB!
http://iriscouch.com/
http://couchbase.com/
http://cloudant.com/
http://couchdb.apache.org/
![Page 28: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/28.jpg)
Apache CouchDBand friends
Iris Couch - single CouchDB “node” hosting; fast & simple setup
Couchbase Server or Cloudant’s BigCouch for big data
more “typical” cluster architectures
Couchbase Mobile for your iOS & Android Devices
PouchDB for browsers - IndexedDB CouchDB
![Page 29: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/29.jpg)
So...
![Page 30: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/30.jpg)
Let’s Replicate......EVERYTHING!!1!
take full advantage of CouchDB
the future is distributednot just data, but...queriesoutput formatsattachmentswhole applicationsand everything else in between
![Page 31: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/31.jpg)
CouchDBdoes replicationyou get to do the other stuff
![Page 32: Why CouchDB?](https://reader036.vdocuments.site/reader036/viewer/2022062307/5550b5eeb4c905ff618b4b35/html5/thumbnails/32.jpg)
Thanks!any questions?
@bigbluehat - github.com/bigbluehat - [email protected]
@couchbase - couchbase.org - [email protected]