Top Banner
CouchDB Apache
74

CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Mar 04, 2018

Download

Documents

nguyentram
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

CouchDBApache

Page 2: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Relax

Page 3: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Hello

• J Chris Anderson

• Apache CouchDB committer

• Web programmer (Rails, Ajax, etc)• Director, couch.io

Page 4: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

About You?

• Web developers are easy

• Scalable key/value store

• Peer-based Replication

• Append-only IO pattern

Page 5: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Scaling Up

• Hot. Literally.

• You don’t have to think.

Page 6: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Scaling Up

• Hot. Literally.

• You don’t have to think.X

Page 7: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Scale Enforces Constraints• Distributed key / value stores

• Context is expensive

• No joins or autoincrement

• Eventual consistency

Page 8: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

e Web Scales

Page 9: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Why CouchDB?Native to the Web

Local data == low latency

Replicated applications

Scale from a cluster to a smartphone

Page 10: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Of the WebLet me tell you something: Django may be built for the Web, but CouchDB is built of the Web. I've never seen software that so completely embraces the philosophies behind HTTP. ... this is what the software of the future looks like.

http://jacobian.org/writing/of-the-web/Jacob Kaplan-MossOctober 19, 2007

Page 11: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Robust

JSON

HTTP

Local

Page 12: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Robust Storage

Append Only File Structure

Designed to Crash

Instant-On

Page 13: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Happy IO Patterns

Page 14: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

JSON Documents

{ "_id": "BCCD12CBB", "_rev": "1-AB764C",

"type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true}

Schema Free

Self-Contained

JavaScript Map Reduce Views

Page 15: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

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 }

ReduceAlice ... Chris: 15

Everyone: 34function(keys, values, rereduce) { return sum(values);}

Page 16: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

JavaScript Map Reduce

Page 17: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 18: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

You already know the API

Use existing HTTP tools

Talk directly to the browser

ful

Page 19: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

ful • Create

HTTP PUT /db/mydocid

• ReadHTTP GET /db/mydocid

• UpdateHTTP PUT /db/mydocid

• DeleteHTTP DELETE /db/mydocid

CRUD

Page 20: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Clustering w/CouchDB-Lounge

Partitioning / clustering proxy

Nginx module

Twisted Python query merge

Makes many machines into one Couch

Page 21: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Local Data

Low latency (fast)

Peer-based incremental replication

View source --> Open source

Page 22: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Gives Control to Users

CC-BY-SA http://www.flickr.com/photos/kelleys/492253912/

Page 23: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Bandwidth Explosion

Page 24: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 25: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 26: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 27: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 28: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 29: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 30: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

“no bars”

Page 32: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 34: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Latency Sucks

Page 35: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Scaling Down4 MB RAM

Page 36: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

ErlangParallel

Fault tolerant

Addictive

Ninja Syntax

Page 37: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Browser CouchJavaScript port

Uses HTML5 storage

Replicates with CouchDB

http://hg.toolness.com/browser-couch/

Page 38: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

No SQLin

HTML5

Page 39: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Incremental Replication

Page 40: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 41: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 42: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 43: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 44: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 45: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 46: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 47: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 48: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 49: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 50: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 51: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 52: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 53: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 54: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Document Oriented• Documents in the Real World™

• Bills, letters, tax forms…

• Same type != same structure

• Self contained

• Can be out of date (so what?)

• No references

Not Relational

Page 55: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Document Oriented• Documents in the Real World™

• Bills, letters, tax forms…

• Same type != same structure

• Can be out of date (so what?)

• No references

Not Relational

Natural Data Behaviour

Page 56: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 57: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 58: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 59: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Render JSON Docs as HTMLshows/post.js /drl/_design/sofa/_show/post/Hello-World-For-Real-This-Time

Page 60: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 61: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Render Views as HTMLlists/index.js /drl/_list/sofa/index/recent-posts?descending=true&limit=8

Page 62: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 63: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 64: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 65: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 66: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 67: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 68: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 69: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many
Page 70: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

anks!

Page 71: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

Resources@CouchDB

http://couchdb.apache.org/

Dress like a Couch: http://shop.couchdb.com

http://planet.couchdb.org/

https://peepcode.com/products/couchdb-with-rails

Page 72: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

http://books.couchdb.org/relax

@couchdbinaction

Page 73: CouchDB Apache - Last.fmstatic.last.fm/johan/nosql-20090611/couchdb_nosql.pdf · CouchDB-Lounge Partitioning / clustering proxy Nginx module Twisted Python query merge Makes many

couch.ioBerlin – London – Portland