The No-Markeng Bullshit Introducon to Couchbase Server 2.0 and ext/couchbase Jan Lehnardt @janl / [email protected]

1 Couchbase Server Features

• Built-in clustering – All nodes equal

• Data replicaon with auto-failover

• Zero-downme maintenance

• Clone to grow and scale horizontally 2 Auto-sharding: vBuckets

3 Couchbase Server Basic Operaon

APP SERVER 1 APP SERVER 2 . Docs distributed evenly across servers in the cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP

SERVER 1 SERVER 2 SERVER 3 Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC

Doc 2 DOC Doc 7 DOC Doc 3 DOC

Doc 9 DOC Doc 8 DOC Doc 6 DOC

COUCHBASE SERVER CLUSTER 4 Couchbase Server Basic Operaon

APP SERVER 1 APP SERVER 2 . Docs distributed evenly across servers in the cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . Each server stores both acve & replica docs . Only one server acve at a me

SERVER 1 SERVER 2 SERVER 3 Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC

Doc 2 DOC Doc 7 DOC Doc 3 DOC

Doc 9 DOC Doc 8 DOC Doc 6 DOC

COUCHBASE SERVER CLUSTER 4 Couchbase Server Basic Operaon

APP SERVER 1 APP SERVER 2 . Docs distributed evenly across servers in the cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . Each server stores both acve & replica docs . Only one server acve at a me . Client library provides app with simple interface to database

SERVER 1 SERVER 2 SERVER 3 Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC

Doc 2 DOC Doc 7 DOC Doc 3 DOC

Doc 9 DOC Doc 8 DOC Doc 6 DOC

COUCHBASE SERVER CLUSTER 4 Couchbase Server Basic Operaon

APP SERVER 1 APP SERVER 2 . Docs distributed evenly across servers in the cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . Each server stores both acve & replica docs . Only one server acve at a me . Client library provides app with simple interface to database . Cluster map provides map to which server doc is on SERVER 1 SERVER 2 SERVER 3 . App never needs to know Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC

Doc 2 DOC Doc 7 DOC Doc 3 DOC

Doc 9 DOC Doc 8 DOC Doc 6 DOC

COUCHBASE SERVER CLUSTER 4 Couchbase Server Basic Operaon

APP SERVER 1 APP SERVER 2 . Docs distributed evenly across servers in the cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . Each server stores both acve & replica docs . Only one server acve at a me . Client library provides app with simple interface to database . Cluster map provides map to which server doc is on SERVER 1 SERVER 2 SERVER 3 . App never needs to know Acve Docs Acve Docs Acve Docs . App reads, writes, updates docs Doc 5 DOC Doc 4 DOC Doc 1 DOC

Doc 2 DOC Doc 7 DOC Doc 3 DOC

Doc 9 DOC Doc 8 DOC Doc 6 DOC

COUCHBASE SERVER CLUSTER 4 Couchbase Server Basic Operaon

APP SERVER 1 APP SERVER 2 . Docs distributed evenly across servers in the cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . Each server stores both acve & replica docs . Only one server acve at a me . Client library provides app with simple interface to database . Cluster map provides map to which server doc is on SERVER 1 SERVER 2 SERVER 3 . App never needs to know Acve Docs Acve Docs Acve Docs . App reads, writes, updates docs Doc 5 DOC Doc 4 DOC Doc 1 DOC . Mulple App Servers can access

Doc 2 DOC Doc 7 DOC Doc 3 DOC same document at same me

Doc 9 DOC Doc 8 DOC Doc 6 DOC

COUCHBASE SERVER CLUSTER 4 Couchbase Server Basic Operaon

APP SERVER 1 APP SERVER 2 . Docs distributed evenly across servers in the cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . Each server stores both acve & replica docs . Only one server acve at a me . Client library provides app with simple interface to database . Cluster map provides map to which server doc is on SERVER 1 SERVER 2 SERVER 3 . App never needs to know Acve Docs Acve Docs Acve Docs . App reads, writes, updates docs Doc 5 DOC Doc 4 DOC Doc 1 DOC . Mulple App Servers can access

Doc 2 DOC Doc 7 DOC Doc 3 DOC same document at same me

Doc 9 DOC Doc 8 DOC Doc 6 DOC

Replica Docs Replica Docs Replica Docs

Doc 4 DOC Doc 6 DOC Doc 7 DOC

Doc 1 DOC Doc 3 DOC Doc 9 DOC

Doc 8 DOC Doc 2 DOC Doc 5 DOC

COUCHBASE SERVER CLUSTER 4 Couchbase Server Basic Operaon

APP SERVER 1 APP SERVER 2 . Docs distributed evenly across servers in the cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . Each server stores both acve & replica docs . Only one server acve at a me . Client library provides app with Read/Write/Update Read/Write/Update simple interface to database . Cluster map provides map to which server doc is on SERVER 1 SERVER 2 SERVER 3 . App never needs to know Acve Docs Acve Docs Acve Docs . App reads, writes, updates docs Doc 5 DOC Doc 4 DOC Doc 1 DOC . Mulple App Servers can access

Doc 2 DOC Doc 7 DOC Doc 3 DOC same document at same me

Doc 9 DOC Doc 8 DOC Doc 6 DOC

Replica Docs Replica Docs Replica Docs

Doc 4 DOC Doc 6 DOC Doc 7 DOC

Doc 1 DOC Doc 3 DOC Doc 9 DOC

Doc 8 DOC Doc 2 DOC Doc 5 DOC

COUCHBASE SERVER CLUSTER 4 Add Nodes

APP SERVER 1 APP SERVER 2

COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP

SERVER 1 SERVER 2 SERVER 3 Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC Doc 3 Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 6 Doc 9 DOC Doc 8 DOC Doc 6 DOC

Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 7 Doc 1 DOC Doc 3 DOC Doc 9 DOC Doc 9 Doc 8 DOC Doc 2 DOC Doc 5 DOC

COUCHBASE SERVER CLUSTER 5 Add Nodes

APP SERVER 1 APP SERVER 2

COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC Doc 3 Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 6 Doc 9 DOC Doc 8 DOC Doc 6 DOC

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 7 Doc 1 DOC Doc 3 DOC Doc 9 DOC Doc 9 Doc 8 DOC Doc 2 DOC Doc 5 DOC

COUCHBASE SERVER CLUSTER 5 Add Nodes

APP SERVER 1 APP SERVER 2

. Two servers added to cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . One-click operaon

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC Doc 3 Doc 9 DOC Doc 6 DOC Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 6 Doc 8 DOC

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 7 Doc 5 DOC Doc 8 DOC Doc 1 DOC Doc 3 DOC Doc 9 DOC Doc 9 Doc 2 DOC

COUCHBASE SERVER CLUSTER 5 Add Nodes

APP SERVER 1 APP SERVER 2

. Two servers added to cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . One-click operaon . Docs automacally rebalanced across cluster . Even distribuon of docs . Minimum doc movement

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC Doc 3 Doc 9 DOC Doc 6 DOC Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 6 Doc 8 DOC

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 7 Doc 5 DOC Doc 8 DOC Doc 1 DOC Doc 3 DOC Doc 9 DOC Doc 9 Doc 2 DOC

COUCHBASE SERVER CLUSTER 5 Add Nodes

APP SERVER 1 APP SERVER 2

. Two servers added to cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . One-click operaon . Docs automacally rebalanced across cluster . Even distribuon of docs . Minimum doc movement . Cluster map updated

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC Doc 3 Doc 9 DOC Doc 6 DOC Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 6 Doc 8 DOC

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 7 Doc 5 DOC Doc 8 DOC Doc 1 DOC Doc 3 DOC Doc 9 DOC Doc 9 Doc 2 DOC

COUCHBASE SERVER CLUSTER 5 Add Nodes

APP SERVER 1 APP SERVER 2

. Two servers added to cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . One-click operaon . Docs automacally rebalanced across cluster . Even distribuon of docs . Minimum doc movement . Cluster map updated . App database calls now distributed over larger # of servers

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC Doc 3 Doc 9 DOC Doc 6 DOC Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 6 Doc 8 DOC

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 7 Doc 5 DOC Doc 8 DOC Doc 1 DOC Doc 3 DOC Doc 9 DOC Doc 9 Doc 2 DOC

COUCHBASE SERVER CLUSTER 5 Add Nodes

APP SERVER 1 APP SERVER 2

. Two servers added to cluster COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY CLUSTER MAP CLUSTER MAP . One-click operaon . Docs automacally rebalanced across cluster . Even distribuon of docs . Minimum doc movement . Cluster map updated Read/Write/Update Read/Write/Update . App database calls now distributed over larger # of servers

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC Doc 3 Doc 9 DOC Doc 6 DOC Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 6 Doc 8 DOC

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 7 Doc 5 DOC Doc 8 DOC Doc 1 DOC Doc 3 DOC Doc 9 DOC Doc 9 Doc 2 DOC

COUCHBASE SERVER CLUSTER 5 Fail Over Node

. App servers happily accessing docs on Server 3 . Server fails COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY . App server requests to server 3 fail CLUSTER MAP CLUSTER MAP . Cluster detects server has failed . Promotes replicas of docs to acve . Updates cluster map . App server requests for docs now go to appropriate server . Typically rebalance would follow

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC DOC DOC Doc 3 Doc 9 Doc 6 Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 8 DOC Doc 6

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 5 DOC Doc 8 DOC Doc 7 Doc 1 DOC Doc 3 DOC Doc 9 DOC Doc 2 DOC Doc 9

COUCHBASE SERVER CLUSTER 6 Fail Over Node

. App servers happily accessing docs on Server 3 . Server fails COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY . App server requests to server 3 fail CLUSTER MAP CLUSTER MAP . Cluster detects server has failed . Promotes replicas of docs to acve . Updates cluster map . App server requests for docs now go to appropriate server . Typically rebalance would follow

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC DOC DOC Doc 3 Doc 9 Doc 6 Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 8 DOC Doc 6

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 5 DOC Doc 8 DOC Doc 7 Doc 1 DOC Doc 3 DOC Doc 9 DOC Doc 2 DOC Doc 9

COUCHBASE SERVER CLUSTER 6 Fail Over Node

. App servers happily accessing docs on Server 3 . Server fails COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY . App server requests to server 3 fail CLUSTER MAP CLUSTER MAP

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC DOC DOC Doc 3 Doc 9 Doc 6 Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 8 DOC DOC Doc 6 Doc 1 Doc 3

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 5 Doc 8 DOC Doc 7 DOC DOC Doc 9 DOC Doc 2 DOC Doc 9

COUCHBASE SERVER CLUSTER 6 Fail Over Node

. App servers happily accessing docs on Server 3 . Server fails COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY . App server requests to server 3 fail CLUSTER MAP CLUSTER MAP . Cluster detects server has failed . Promotes replicas of docs to acve . Updates cluster map

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC DOC DOC Doc 3 Doc 9 Doc 6 Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 8 DOC DOC Doc 6 Doc 1 Doc 3

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 5 Doc 8 DOC Doc 7 DOC DOC Doc 9 DOC Doc 2 DOC Doc 9

COUCHBASE SERVER CLUSTER 6 Fail Over Node

. App servers happily accessing docs on Server 3 . Server fails COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY . App server requests to server 3 fail CLUSTER MAP CLUSTER MAP . Cluster detects server has failed . Promotes replicas of docs to acve . Updates cluster map . App server requests for docs now go to appropriate server

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC DOC DOC Doc 3 Doc 9 Doc 6 Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 8 DOC DOC Doc 6 Doc 1 Doc 3

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 5 Doc 8 DOC Doc 7 DOC DOC Doc 9 DOC Doc 2 DOC Doc 9

COUCHBASE SERVER CLUSTER 6 Fail Over Node

. App servers happily accessing docs on Server 3 . Server fails COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY . App server requests to server 3 fail CLUSTER MAP CLUSTER MAP . Cluster detects server has failed . Promotes replicas of docs to acve . Updates cluster map . App server requests for docs now go to appropriate server . Typically rebalance would follow

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC DOC DOC Doc 3 Doc 9 Doc 6 Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 8 DOC DOC Doc 6 Doc 1 Doc 3

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 5 Doc 8 DOC Doc 7 DOC DOC Doc 9 DOC Doc 2 DOC Doc 9

COUCHBASE SERVER CLUSTER 6 Fail Over Node

. App servers happily accessing docs on Server 3 . Server fails COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY . App server requests to server 3 fail CLUSTER MAP CLUSTER MAP . Cluster detects server has failed . Promotes replicas of docs to acve . Updates cluster map . App server requests for docs now go to appropriate server . Typically rebalance would follow

SERVER 1 SERVER 2 SERVER 3 SERVER 4 SERVER 5 Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC DOC DOC Doc 3 Doc 9 Doc 6 Doc 2 DOC Doc 7 DOC Doc 3 DOC Doc 8 DOC DOC Doc 6 Doc 1 Doc 3

Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Replica Docs Doc 4 DOC Doc 6 DOC Doc 7 DOC Doc 5 Doc 8 DOC Doc 7 DOC DOC Doc 9 DOC Doc 2 DOC Doc 9

COUCHBASE SERVER CLUSTER 6 Couchbase Server Features

compable (built-in caching)

• Monitoring and administraon APIs and GUI

• Reliable storage architecture

7 Couchbase Server 1.8 Architecture

11211 11210 Memcapable 1.0 Memcapable 2.0

Moxi

Memcached

DataCouchbase Manager EP Engine Cluster Manager storage interface Heartbeat Process monitor Node health monitor health Node Configuraon manager Rebalance orchestrator Rebalance Global singleton supervisor RESTmanagement API/Web UI vBucket state and replicaon manager Persistence Layer hp on each node one per cluster

Erlang/OTP

HTTP Erlang port mapper Distributed Erlang 8091 4369 21100 - 21199 8 CAPI interface – basic Couch API of which some goes through the caching layer (CRUD), some goes directly to Couch (Views) Couchbase Server 1.8 Architecture

11211 11210 Memcapable 1.0 Memcapable 2.0

Moxi

Memcached

Couchbase EP Engine

storage interface Heartbeat Process monitor Node health monitor health Node Configuraon manager Rebalance orchestrator Rebalance Global singleton supervisor RESTmanagement API/Web UI vBucket state and replicaon manager Persistence Layer hp on each node one per cluster

Erlang/OTP

HTTP Erlang port mapper Distributed Erlang 8091 4369 21100 - 21199 9 CAPI interface – basic Couch API of which some goes through the caching layer (CRUD), some goes directly to Couch (Views) Couchbase Server 1.8 Architecture

11211 11210 Memcapable 1.0 Memcapable 2.0

Moxi

Memcached

Couchbase EP Engine Heartbeat

storage interface Process monitor Node health monitor health Node ConfiguraonManager Rebalance orchestrator Rebalance Global singleton supervisor RESTManagement /WebUI vBucket state and replicaon manager Persistence Layer hp on each node one per cluster

Erlang/OTP

HTTP Erlang port mapper Distributed Erlang 8091 4369 21100 - 21199 10 Couchbase SDKs

PHP SDK User Code

.Net SDK set("key", "value"); ...

Java SDK libcouchbase

Ruby SDK Couchbase Server …and many more hp://www.couchbase.com/develop 11 Couchbase Server 2.0

• Next major release of Couchbase Server • Currently in Developer Preview

What’s new: • Indexing and Querying • Incremental Map Reduce • Cross Data Center Replicaon

• Fully backwards compable with exisng Couchbase Server

12 Couchbase Server 2.0 Architecture

8092 11211 11210 Query API Memcapable 1.0 Memcapable 2.0

Moxi

Memcached

Query Engine Query Couchbase EP Engine

storage interface Heartbeat Process monitor Node health monitor health Node Configuraon manager Rebalance orchestrator Rebalance Global singleton supervisor RESTmanagement API/Web UI vBucket state and replicaon manager

New Persistence Layer hp on each node one per cluster

Erlang/OTP

HTTP Erlang port mapper Distributed Erlang 8091 4369 21100 - 21199 13 Couchbase Server 2.0 Architecture

8092 11211 11210 Query API Memcapable 1.0 Memcapable 2.0

Moxi

Memcached

Query Engine Query Couchbase EP Engine

storage interface Heartbeat Process monitor Node health monitor health Node Configuraon manager Rebalance orchestrator Rebalance Global singleton supervisor RESTmanagement API/Web UI vBucket state and replicaon manager

New Persistence Layer hp on each node one per cluster

Erlang/OTP

HTTP Erlang port mapper Distributed Erlang 8091 4369 21100 - 21199 13 Indexing and Querying

APP SERVER 1 APP SERVER 2

APP SERVER 1 APP SERVER 2 . Indexing work is distributed COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY COUCHBASECLUSTER CLIENT LIBRARY MAP COUCHBASECLUSTER CLIENT LIBRARY MAP CLUSTER MAP CLUSTER MAP amongst nodes . Large data set possible . Parallelize the effort

SERVER 1 SERVER 2 SERVER 3 Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC

Doc 2 DOC Doc 7 DOC Doc 3 DOC

Doc 9 DOC Doc 8 DOC Doc 6 DOC

Replica Docs Replica Docs Replica Docs

Doc 4 DOC Doc 6 DOC Doc 7 DOC

Doc 1 DOC Doc 3 DOC Doc 9 DOC

Doc 8 DOC Doc 2 DOC Doc 5 DOC

14 Indexing and Querying

APP SERVER 1 APP SERVER 2

APP SERVER 1 APP SERVER 2 . Indexing work is distributed COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY COUCHBASECLUSTER CLIENT LIBRARY MAP COUCHBASECLUSTER CLIENT LIBRARY MAP CLUSTER MAP CLUSTER MAP amongst nodes . Large data set possible . Parallelize the effort . Each node has index for data stored on it

SERVER 1 SERVER 2 SERVER 3 Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC

Doc 2 DOC Doc 7 DOC Doc 3 DOC

Doc 9 DOC Doc 8 DOC Doc 6 DOC

Replica Docs Replica Docs Replica Docs

Doc 4 DOC Doc 6 DOC Doc 7 DOC

Doc 1 DOC Doc 3 DOC Doc 9 DOC

Doc 8 DOC Doc 2 DOC Doc 5 DOC

14 Indexing and Querying

APP SERVER 1 APP SERVER 2

APP SERVER 1 APP SERVER 2 . Indexing work is distributed COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY COUCHBASECLUSTER CLIENT LIBRARY MAP COUCHBASECLUSTER CLIENT LIBRARY MAP CLUSTER MAP CLUSTER MAP amongst nodes . Large data set possible . Parallelize the effort . Each node has index for data Query stored on it

SERVER 1 SERVER 2 SERVER 3 Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC

Doc 2 DOC Doc 7 DOC Doc 3 DOC

Doc 9 DOC Doc 8 DOC Doc 6 DOC

Replica Docs Replica Docs Replica Docs

Doc 4 DOC Doc 6 DOC Doc 7 DOC

Doc 1 DOC Doc 3 DOC Doc 9 DOC

Doc 8 DOC Doc 2 DOC Doc 5 DOC

14 Indexing and Querying

APP SERVER 1 APP SERVER 2

APP SERVER 1 APP SERVER 2 . Indexing work is distributed COUCHBASE CLIENT LIBRARY COUCHBASE CLIENT LIBRARY COUCHBASECLUSTER CLIENT LIBRARY MAP COUCHBASECLUSTER CLIENT LIBRARY MAP CLUSTER MAP CLUSTER MAP amongst nodes . Large data set possible . Parallelize the effort . Each node has index for data Response stored on it . Queries combine the results from required nodes SERVER 1 SERVER 2 SERVER 3 Acve Docs Acve Docs Acve Docs Doc 5 DOC Doc 4 DOC Doc 1 DOC

Doc 2 DOC Doc 7 DOC Doc 3 DOC

Doc 9 DOC Doc 8 DOC Doc 6 DOC

Replica Docs Replica Docs Replica Docs

Doc 4 DOC Doc 6 DOC Doc 7 DOC

Doc 1 DOC Doc 3 DOC Doc 9 DOC

Doc 8 DOC Doc 2 DOC Doc 5 DOC

14 Cross Data Center Replicaon

US DATA EUROPE DATA ASIA DATA CENTER CENTER CENTER Replicaon Replicaon

Replicaon

. Want data close to user . Want mulple locaons for disaster recovery

. Mul-Master: Can write to same document in all different regions & it will sync (eventually consistent, always available) 15 Not yet enabled in current DP, will be available for Beta EXT/COUCHBASE

16 Setup

17 Basics

set("a", 1);

$a = $cb->get("a"); echo $a; // prints 1

$cb->increment("a"); echo $cb->get("a"); // prints 2

$cb->delete("a"); // booya 18 Storage Operaons

set("a", 1);

// fails if "b" exists $cb->add("b", 1);

// fails if "" doesn't exit $cb->replace("c", 1);

19 Expiraon

set("a", 1, 10);

// most other ops can set expire

// just update the expiry $cb->touch("a", 10);

20 Compare And Swap

get("a", null, &$cas); echo $cas; // prints 76324827359

// fails if cas doesn't match $cb->cas($cas, "a", 2);

21 Arithmec

set("a", 1); // "a" is 1 $cb->increment("a"); // "a" is 2 $cb->increment("a", 2); // "a" is 4 $cb->decrement("a", 4); // "a" is 0

22 Arithmec 2

// increment($key, $offset, // $create, $expiry, $initial)

$cb->increment("b", 3, true, 0, 2); 23 QUESTIONS?

24 THANK YOU!

Get Couchbase Server 2.0 at hp://www.couchbase.com/downloads

Give us feedback at: hp://www.couchbase.com/forums

25