Couchdb + Membase = Couchbase

37
1 DALE HARVEY Data management for interactive web and mobile applications.

description

Couchdb + Membase = Couchbase

Transcript of Couchdb + Membase = Couchbase

Page 1: Couchdb + Membase = Couchbase

1

DALE HARVEY

Data management for interactive web and mobile applications.

Page 2: Couchdb + Membase = Couchbase

@perezd

RELAX

Page 3: Couchdb + Membase = Couchbase

What is Couchbase?

3

1+1 really does equal 3

Page 4: Couchdb + Membase = Couchbase

WHAT IS MEMBASE?

4

Page 5: Couchdb + Membase = Couchbase

Leading cloud service (PAAS) providerOver 65,000 hosted applicationsMembase Server serving over 1,200 Heroku customers (as of June 10, 2010)

Deployments Leading Membase

5

Social game leader – FarmVille, Mafia Wars, Café WorldOver 230 million monthly usersMembase Serveris the 500,000 ops-per-second database behind FarmVille and Café World

Page 6: Couchdb + Membase = Couchbase

Ad targeting

6

eventsprofiles, campaigns

profiles, real time campaign statistics

40 milliseconds to come up with an answer.

2

3

1

Page 7: Couchdb + Membase = Couchbase

Membase is a distributed database

7

Membase Servers

In the data center

Web application server

Application user

On the administrator console

Web application serverWeb application server

Page 8: Couchdb + Membase = Couchbase

Five minutes or less to a working cluster• Downloads for Linux and Windows• Start with a single node• One button press joins nodes to a clusterEasy to develop against• Just SET and GET – no schema required• Drop it in. 10,000+ existing applications

already “speak membase” (via memcached)• Practically every language and application

framework is supported, out of the boxEasy to manage• One-click failover and cluster rebalancing• Graphical and programmatic interfaces• Configurable alerting

Membase is Simple, Fast, Elastic

8

Page 9: Couchdb + Membase = Couchbase

Data is sharded into vBuckets

9

Page 10: Couchdb + Membase = Couchbase

Clustering With Membase

10

SET request arrives at KEY’s master server

Listener-Sender

Master server for KEY Replica Server 2 for KEYReplica Server 1 for KEY

3 3

1 SET acknowledgement returned to application2

DiskDisk Disk

RAM

mem

base

sto

rage

eng

ine

DiskDisk Disk

4

Page 11: Couchdb + Membase = Couchbase

Membase is Simple, Fast, Elastic

11

Zero-downtime elasticity• Spread I/O and data across commodity

servers (or VMs) • Consistent performance with linear cost• Dynamic rebalancing of a live clusterAll nodes are created equal• No special case nodes• Any node can replace any other node, online• Clone to growExtensible• Filtered TAP interface provides hook points

for external systems (e.g. full-text search, backup, warehouse)

• Data bucket – engine API for specialized container types

Page 12: Couchdb + Membase = Couchbase

WHAT IS CouchDB?

12

Page 13: Couchdb + Membase = Couchbase

Robust

JSON

Replication

Map Reduce

GeoCouch

HTTP

13

Page 14: Couchdb + Membase = Couchbase

USE CASES

14

Page 15: Couchdb + Membase = Couchbase

DOCUMENT STORE

15

{ “_id” : “uniqueid”, “_rev” : 1234567, “title” : “My New Blog Post”, “body” : “A quick brown fox .......”, “_attachments”: { “profile.jpg”: { ...... } }}

=> PUT http://127.0.0.1:5984/mydatabase/uniqueid

=> GET http://127.0.0.1:5984/mydatabase/uniqueid

=> DELETE http://127.0.0.1:5984/mydatabase/uniqueid

=> POST http://127.0.0.1:5984/mydatabase

Page 16: Couchdb + Membase = Couchbase

ROBUST STORAGE ENGINE

16

Append-OnlyReliable & ConcurrentHot BackupsCompaction

Page 17: Couchdb + Membase = Couchbase

INCREMENTAL MAP REDUCE

17

Page 18: Couchdb + Membase = Couchbase

PEER-BASED REPLICATION

18

curl -X POST http://127.0.0.1:5984/_replicate -d '{ "source": "http://couch.example.com:5984/remote-db",

"target": "local-db"

}'

Page 19: Couchdb + Membase = Couchbase

• Extremely Robust Storage EngineConsumer devices may lose power at any time

• Lightweight RuntimeSmall install, low memory footprint, easy on battery life

• Offline sync via ReplicationMulti-master synchronization engine

• GeoSpatial IndexMapping and location aware apps

• HTML5 Application ServerEasy to add a web view to your mobile data

19

NAILING MOBILE

https://github.com/couchbaselabs/iOS-Couchbase

Page 20: Couchdb + Membase = Couchbase

20

GEOCOUCHCIVICAPI.COM, ETC

Advanced R-Tree Index

Page 21: Couchdb + Membase = Couchbase

ARCHITECTURE

Page 22: Couchdb + Membase = Couchbase

2.0 Architecture Overview

22

Couchbase SDK API

Application

MCD Couch

Memcached

ep_engine

Couchbase Server

Couch Proxy

vBucket Data View Data

Application Tier

Elastic Couchbase Server Cluster

Moxi

Cluster Manager

Page 23: Couchdb + Membase = Couchbase

5

JSON Document Handling

• Per Bucket JSON Document Mode toggle

• JSON Document Mode disabled (or invalid JSON)– Values are opaque to couch (and in views)– Stored as attachments to documents that hold

metadata– Returned values are guaranteed bitwise identical

• JSON Document Mode enabled– Values are expected to be valid JSON– Stored in document along metadata– Returned values may not be bitwise identical but

Page 24: Couchdb + Membase = Couchbase

JSON Document Encodings for memcached

24

Meta DataKey:”zdfasf” Expiration:43452345 Flags:2352145

JSON Document

{ “foo”: ”bar”

}

Meta DataKey:”zdfasf” Expiration:43452345 Flags:2352145

Value

0x87632f98,0xa76b876d, …!

Couch Document

Couch Document

{ “_id”: ”zdfasf” “$Expiration”: 43452345, “$Flags”: 2352145, “$AttachReason”:”JSON Mode Disabled”, //Other

reasons “Invalid JSON”, etc. [“$KeyMangled”: false,] //only included if true “_attachments”: { “$value”: { … } }

}

{ “_id”: ”zdfasf” “$Expiration”: 43452345, “$Flags”: 2352145, [“$KeyMangled”: false,] //only included if true “foo”: ”bar”

}

Page 25: Couchdb + Membase = Couchbase

8

Scatter Gather Map Reduce

• Get next answer from local vBuckets and from child nodes to select the next result for a node

• Result includes info on number of vBuckets not included– Timeouts, Incorrect Design Doc version, etc

Page 26: Couchdb + Membase = Couchbase

9

Scatter Gather Example

Page 27: Couchdb + Membase = Couchbase

10

Scatter Gather Example

Page 28: Couchdb + Membase = Couchbase

11

Scatter Gather Example

Page 29: Couchdb + Membase = Couchbase

12

Scatter Gather Example

Page 30: Couchdb + Membase = Couchbase

13

Scatter Gather Example

Page 31: Couchdb + Membase = Couchbase

14

Scatter Gather Example

Page 32: Couchdb + Membase = Couchbase

15

Scatter Gather Example

Page 33: Couchdb + Membase = Couchbase

16

Scatter Gather Example

Page 34: Couchdb + Membase = Couchbase

17

Scatter Gather Example

Page 35: Couchdb + Membase = Couchbase

18

Scatter Gather Example

Page 36: Couchdb + Membase = Couchbase

19

Scatter Gather Example