vidoop couchdb talk
DESCRIPTION
Overview of CouchDB,Demo of CouchApp,Future of Distributed IdentityTRANSCRIPT
Couch History
• Damien Katz <http://damienkatz.net/>
• Worked on Lotus Notes & MySQL
• Started CouchDB in 2005
• 2006: Moved to Erlang, JSON and JavaScript
• Approaching 0.9 Release
2008 Erlang User of the Year
This Talk
• Hello CouchDB
• Hands on with CouchApp
• The Future
• Get Involved
Hello CouchDB• JSON Documents
• HTTP / REST (You already know the API)
• ACID Storage Engine
• Map Reduce Views
• Replication for Freedom
• Portable Standalone Applications
JSON Documents
{“json” : “key / value pairs”,“_id” : “some uuid”,“_rev” : “mvcc key”,
“string keys” : [1,2,3,”four”,null],“schema free” : true}
Your programming language supports JSON.
JSON Documents
{“json” : “key / value pairs”,“_id” : “some uuid”,“_rev” : “mvcc key”,
“string keys” : [1,2,3,”four”,null],“schema free” : “flexible”}
Adapt data as your application changes.
HTTP / CRUD
GET read
PUT create or update
DELETE delete
POST bulk operation
You already know the API.
ACID Storage Engine
• Append Only
• Multi Version Concurrency Control
• B-Tree Indexes O(log n)
• Attachment Streaming
Oooh, self-similar
Map Reduce ViewsDocs Map
{ “user” : “Chris”,“points” : 3 }
{ “user” : “Joe”,“points” : 10 }
{ “user” : “Alice”,“points” : 5 }
{ “user” : “Mary”,“points” : 9 }
{ “user” : “Bob”,“points” : 7 }
function(doc) {if (doc.user && doc.points) {
emit(doc.user, doc.points);}
}
{ “key” : “Alice”, “value” : 5 }{ “key” : “Bob”, “value” : 7 }
{ “key” : “Chris”, “value” : 3 }{ “key” : “Joe”, “value” : 10 }{ “key” : “Mary”, “value” : 9 }
Reduce
Alice ... Chris: 15Everyone: 34
function(keys, values, rereduce) { return sum(values);}
Peer-Based Replication for Freedom
TriggeredIncremental
Filtered*
Let’s Replicate Everything!
• Take full advantage of CouchDB
• View-source Open Source
• The Future is Distributed
But that’s not RESTful!Representational State Transfer...
it’s more than just verbs,it’s the hyperlinks.
Webpage
Webpage
Webpage
Webpage
∴We need HTML.
Render JSON Docs as HTMLshows/post.js /drl/_show/sofa/post/Hello-World-For-Real-This-Time
Render Views as HTMLlists/index.js /drl/_list/sofa/index/recent-posts?descending=true&limit=8
Hands On with CouchApp
• CouchApp is just some filesystem helpers
• Embodies “best practices”
• CouchApp is not opinionated, CouchDB is.
• Don’t shoot the messenger.
Install CouchApp
sudo easy_install couchapp
or
git clone git://github.com/jchris/couchapp.git
Check Your CouchDB
http://127.0.0.1:5984/_utils/
Setup Credentials
edit: /usr/local/etc/couchdb/local.ini
add:[admins]
username = secretpassword
Leaky Abstraction!
Get the Example App(ajax version)
couchapp clone http://jchrisa.net/sofa-ajax/_design/sofa
cd sofa
couchapp pushhttp://user:pass@localhost:5984/sofa-ajax
The Guts
First Post!
Firebug to see requests
Upgrade to real HTML
couchapp clone http://jchrisa.net/drl/_design/sofa
cd sofa
couchapp pushhttp://user:pass@localhost:5984/sofa
How’s it Work?
Macros so functions can be in multiple files.
Templating
The Future
• Key-Centric Identity?
• P2P Topologies don’t leave room to trust the server.
• Multi-Node clusters
• High performance, large databases
Resources
• #couchdb and #couchapp on irc.freenode.net
• http://couchdb.apache.org for mailing lists
• http://planet.couchdb.org/
• http://books.couchdb.org/relax/
• Twitter search for “couchdb”
Thank You!