36
1 Introduction to Couchbase Server 2.0 Dipti Borkar Director, Product Management

Introduction to couchbase server 20 12012012

Embed Size (px)

Citation preview

Page 1: Introduction to couchbase server 20 12012012

1

Introduction to

Couchbase Server 2.0

Dipti Borkar

Director, Product Management

Page 2: Introduction to couchbase server 20 12012012

2

2.0

NoSQL Document

Database

Couchbase Server

Page 3: Introduction to couchbase server 20 12012012

3

Easy Scalability

Consistent High Performance

Always On

24x365

Grow cluster without application changes, without downtime with a single click

Consistent sub-millisecond read and write response times

with consistent high throughput

No downtime for software upgrades, hardware maintenance, etc.

Couchbase Server

JSONJSON

JSON

JSONJSON

Flexible Data Model

JSON document model with no fixed schema.

Page 4: Introduction to couchbase server 20 12012012

4

Flexible Data Model

• No need to worry about the database when changing your application

• Records can have different structures, there is no fixed schema

• Allows painless data model changes for rapid application development

{“ID”: 1,“FIRST”: “Dipti”,“LAST”: “Borkar”,“ZIP”: “94040”,“CITY”: “MV”,“STATE”: “CA”

}JSON

JSONJSON JSON

Page 5: Introduction to couchbase server 20 12012012

5

Couchbase Server Features

Built-in clustering – All nodes equal

Data replication with auto-failover

Zero-­downtime maintenance

Clone to grow and scale horizontally

Built-in managed cached

Monitoring and administration APIs and GUI

SDK for a variety of languages

Page 6: Introduction to couchbase server 20 12012012

6

New in 2.0

JSON support Indexing and Querying

Cross data center replicationIncremental Map Reduce

JSONJSON

JSON

JSONJSON

Page 7: Introduction to couchbase server 20 12012012

7

Couchbase Server 2.0 Architecture

Hea

rtb

eat

Pro

cess

mo

nit

or

Glo

bal

sin

glet

on

su

per

viso

r

Co

nfi

gura

tio

n m

anag

er

on each node

Reb

alan

ce o

rch

estr

ato

r

No

de

hea

lth

mo

nit

or

one per cluster

vBu

cket

sta

te a

nd

rep

licat

ion

man

ager

httpR

EST

man

age

me

nt

AP

I/W

eb

UI

HTTP

8091Erlang port mapper

4369Distributed Erlang

21100 - 21199

Erlang/OTP

storage interface

Couchbase EP Engine

11210Memcapable 2.0

Moxi

11211Memcapable 1.0

Memcached

New Persistence Layer

8092Query API

Qu

ery

En

gin

e

Data Manager Cluster Manager

Page 8: Introduction to couchbase server 20 12012012

8

Couchbase Server 2.0 Architecture

Hea

rtb

eat

Pro

cess

mo

nit

or

Glo

bal

sin

glet

on

su

per

viso

r

Co

nfi

gura

tio

n m

anag

er

on each node

Reb

alan

ce o

rch

estr

ato

r

No

de

hea

lth

mo

nit

or

one per cluster

vBu

cket

sta

te a

nd

rep

licat

ion

man

ager

httpR

EST

man

age

me

nt

AP

I/W

eb

UI

HTTP

8091Erlang port mapper

4369Distributed Erlang

21100 - 21199

Erlang/OTP

storage interface

Couchbase EP Engine

11210Memcapable 2.0

Moxi

11211Memcapable 1.0

Object-level Cache

New Persistence Layer

8092Query API

Qu

ery

En

gin

e

Page 9: Introduction to couchbase server 20 12012012

9

Couchbase deployment

Data Flow

Cluster Management

Web Application

CouchbaseClient Library

Page 10: Introduction to couchbase server 20 12012012

10

COUCHBASE OPERATIONS

Page 11: Introduction to couchbase server 20 12012012

11

33 2

Single node - Couchbase Write Operation

2

Managed Cache

Dis

k Q

ueu

e

Disk

Replication Queue

App Server

Couchbase Server Node

Doc 1Doc 1

Doc 1

To other node

Page 12: Introduction to couchbase server 20 12012012

12

33 2

Single node - Couchbase Update Operation

2

Managed Cache

Dis

k Q

ueu

e

Replication Queue

App Server

Couchbase Server Node

Doc 1’

Doc 1

Doc 1’Doc 1

Doc 1’

Disk

To other node

Page 13: Introduction to couchbase server 20 12012012

13

GET

Do

c 1

33 2

Single node - Couchbase Read Operation

2

Dis

k Q

ueu

e

Replication Queue

App Server

Couchbase Server Node

Doc 1

Doc 1Doc 1

Managed Cache

Disk

To other node

Page 14: Introduction to couchbase server 20 12012012

14

33 2

Single node - Couchbase Cache Eviction

2

Dis

k Q

ueu

e

Replication Queue

App Server

Couchbase Server Node

Doc 1

Doc 6Doc 5Doc 4Doc 3Doc 2

Doc 1

Doc 6 Doc 5 Doc 4 Doc 3 Doc 2

Managed Cache

Disk

To other node

Page 15: Introduction to couchbase server 20 12012012

15

33 2

Single node – Couchbase Cache Miss

2

Dis

k Q

ueu

e

Replication Queue

App Server

Couchbase Server Node

Doc 1

Doc 3Doc 5 Doc 2Doc 4

Doc 6 Doc 5 Doc 4 Doc 3 Doc 2

Doc 4

GET

Do

c 1

Doc 1

Doc 1

Managed Cache

Disk

To other node

Page 16: Introduction to couchbase server 20 12012012

16

COUCHBASE SERVER CLUSTER

Cluster wide - Basic Operation

• Docs distributed evenly across servers

• Each server stores both active and replica docsOnly one server active at a time

• Client library provides app with simple interface to database

• Cluster map provides map to which server doc is onApp never needs to know

• App reads, writes, updates docs

• Multiple app servers can access same document at same time

User Configured Replica Count = 1

READ/WRITE/UPDATE

ACTIVE

Doc 5

Doc 2

Doc

Doc

Doc

SERVER 1

ACTIVE

Doc 4

Doc 7

Doc

Doc

Doc

SERVER 2

Doc 8

ACTIVE

Doc 1

Doc 2

Doc

Doc

Doc

REPLICA

Doc 4

Doc 1

Doc 8

Doc

Doc

Doc

REPLICA

Doc 6

Doc 3

Doc 2

Doc

Doc

Doc

REPLICA

Doc 7

Doc 9

Doc 5

Doc

Doc

Doc

SERVER 3

Doc 6

APP SERVER 1

COUCHBASE Client Library

CLUSTER MAP

COUCHBASE Client Library

CLUSTER MAP

APP SERVER 2

Doc 9

Page 17: Introduction to couchbase server 20 12012012

17

Cluster wide - Add Nodes to Cluster

• Two servers addedOne-click operation

• Docs automatically rebalanced across clusterEven distribution of docsMinimum doc movement

• Cluster map updated

• App database calls now distributed over larger number of servers

REPLICA

ACTIVE

Doc 5

Doc 2

Doc

Doc

Doc 4

Doc 1

Doc

Doc

SERVER 1

REPLICA

ACTIVE

Doc 4

Doc 7

Doc

Doc

Doc 6

Doc 3

Doc

Doc

SERVER 2

REPLICA

ACTIVE

Doc 1

Doc 2

Doc

Doc

Doc 7

Doc 9

Doc

Doc

SERVER 3 SERVER 4 SERVER 5

REPLICA

ACTIVE

REPLICA

ACTIVE

Doc

Doc 8 Doc

Doc 9 Doc

Doc 2 Doc

Doc 8 Doc

Doc 5 Doc

Doc 6

READ/WRITE/UPDATE READ/WRITE/UPDATE

APP SERVER 1

COUCHBASE Client Library

CLUSTER MAP

COUCHBASE Client Library

CLUSTER MAP

APP SERVER 2

COUCHBASE SERVER CLUSTER

User Configured Replica Count = 1

Page 18: Introduction to couchbase server 20 12012012

18

Cluster wide - Fail Over Node

REPLICA

ACTIVE

Doc 5

Doc 2

Doc

Doc

Doc 4

Doc 1

Doc

Doc

SERVER 1

REPLICA

ACTIVE

Doc 4

Doc 7

Doc

Doc

Doc 6

Doc 3

Doc

Doc

SERVER 2

REPLICA

ACTIVE

Doc 1

Doc 2

Doc

Doc

Doc 7

Doc 9

Doc

Doc

SERVER 3 SERVER 4 SERVER 5

REPLICA

ACTIVE

REPLICA

ACTIVE

Doc 9

Doc 8

Doc Doc 6 Doc

Doc

Doc 5 Doc

Doc 2

Doc 8 Doc

Doc

• App servers accessing docs

• Requests to Server 3 fail

• Cluster detects server failedPromotes replicas of docs to activeUpdates cluster map

• Requests for docs now go to appropriate server

• Typically rebalance would follow

Doc

Doc 1 Doc 3

APP SERVER 1

COUCHBASE Client Library

CLUSTER MAP

COUCHBASE Client Library

CLUSTER MAP

APP SERVER 2

User Configured Replica Count = 1

COUCHBASE SERVER CLUSTER

Page 19: Introduction to couchbase server 20 12012012

19

DEMO TIME

Page 20: Introduction to couchbase server 20 12012012

20

Indexing and Querying – The basics

• Define materialized views on JSON documents and then query across the data set

• Using views you can define• Primary indexes

• Simple secondary indexes (most common use case)

• Complex secondary, tertiary and composite indexes

• Aggregations (reduction)

• Indexes are eventually indexed

• Queries are eventually consistent with respect to documents

• Built using Map/Reduce technology • Map and Reduce functions are written in Javascript

Page 21: Introduction to couchbase server 20 12012012

21

33 2

Eventually indexed Views – Data flow

2

Managed Cache

Dis

k Q

ueu

e

Disk

Replication Queue

App Server

Couchbase Server Node

Doc 1Doc 1

Doc 1

To other node

View engine

Doc 1

Page 22: Introduction to couchbase server 20 12012012

22

COUCHBASE SERVER CLUSTER

Cluster wide - Indexing and Querying

User Configured Replica Count = 1

ACTIVE

Doc 5

Doc 2

Doc

Doc

Doc

SERVER 1

REPLICA

Doc 4

Doc 1

Doc 8

Doc

Doc

Doc

APP SERVER 1

COUCHBASE Client Library

CLUSTER MAP

COUCHBASE Client Library

CLUSTER MAP

APP SERVER 2

Doc 9

• Indexing work is distributed amongst nodes

• Large data set possible

• Parallelize the effort

• Each node has index for data stored on it

• Queries combine the results from required nodes

ACTIVE

Doc 5

Doc 2

Doc

Doc

Doc

SERVER 2

REPLICA

Doc 4

Doc 1

Doc 8

Doc

Doc

Doc

Doc 9

ACTIVE

Doc 5

Doc 2

Doc

Doc

Doc

SERVER 3

REPLICA

Doc 4

Doc 1

Doc 8

Doc

Doc

Doc

Doc 9

Query

Page 23: Introduction to couchbase server 20 12012012

23

Cross Data Center Replication – The basics

• Replicate your Couchbase data across clusters

• Clusters may be spread across geos

• Configured on a per-bucket basis

• Supports unidirectional and bidirectional operation

• Application can read and write from both clusters (active – active replication)

• Replication throughput scales out linearly

• Different from intra-cluster replication

Page 24: Introduction to couchbase server 20 12012012

24

33 2

Cross data center replication – Data flow

2

Managed Cache

Dis

k Q

ueu

e

Disk

Replication Queue

App Server

Couchbase Server Node

Doc 1Doc 1

Doc 1

To other node

XDCR Queue

Doc 1

To other cluster

Page 25: Introduction to couchbase server 20 12012012

25

Cluster wide - XDCR

COUCHBASE SERVER CLUSTERNY DATA CENTER

ACTIVE

Doc

Doc 2

SERVER 1

Doc 9

SERVER 2 SERVER 3

RAM

Doc Doc Doc

ACTIVE

Doc

Doc

Doc

RAM

ACTIVE

Doc

Doc

Doc

RAM

DISK

Doc Doc Doc

DISK

Doc Doc Doc

DISK

COUCHBASE SERVER CLUSTERSF DATA CENTER

ACTIVE

Doc

Doc 2

SERVER 1

Doc 9

SERVER 2 SERVER 3

RAM

Doc Doc Doc

ACTIVE

Doc

Doc

Doc

RAM

ACTIVE

Doc

Doc

Doc

RAM

DISK

Doc Doc Doc

DISK

Doc Doc Doc

DISK

Page 26: Introduction to couchbase server 20 12012012

26

DEMO TIME

Page 27: Introduction to couchbase server 20 12012012

27

Demo: The next big social game

3 Objects (documents) within game:• Players• Monsters• Items

Gameplay:

• Players fight monsters

• Monsters drop items

• Players own items

Page 28: Introduction to couchbase server 20 12012012

28

Player Document

{

"jsonType": "player",

"uuid": "35767d02-a958-4b83-8179-616816692de1",

"name": "Keith4540",

"hitpoints": 75,

"experience": 663,

"level": 4,

"loggedIn": false

}

Player ID

Page 29: Introduction to couchbase server 20 12012012

29

Item Document

{

"jsonType": "item",

"name": "Katana_e5890c94-11c6-65746ce6c560",

"uuid": "e5890c94-11c6-4856-a7a6-65746ce6c560",

"ownerId": "Dale9887"

}

Item ID

Player ID

Page 30: Introduction to couchbase server 20 12012012

30

Monster Document

{

"jsonType": "monster",

"name": "Bauchan9932",

"uuid": "d10dfc1b-0412-4140-b4ec-affdbf2aa5ec",

"hitpoints": 370,

"experienceWhenKilled": 52,

"itemProbability": 0.5050581341872865

}

Monster ID

Page 31: Introduction to couchbase server 20 12012012

31

GAME ON!

Page 32: Introduction to couchbase server 20 12012012

32

Full Text Search Integration

• Elastic Search is good for ad-hoc queries and faceted browsing• Couchbase adapter uses XDCR to push mutations to ESDocs

are indexed by Elastic Search• Couchbase ES Adapter is cluster-aware

ElasticSearch

Unidirectional Cross Data Center Replication

Page 33: Introduction to couchbase server 20 12012012

33

Full Text Search

Data

MR Query

Application Server

ES Queries over HTTPCouchbase SDK

MR

Views

MR

Views

MR

Views

MR

Views

Couchbase Server Cluster ElasticSearch Server Cluster

TS Query

Doc Refs

Cross Data Center ReplicationXDCR-based

CB-ES Transport

Page 34: Introduction to couchbase server 20 12012012

34

Couchbase SDKs

Java SDK

.Net SDK

PHP SDK

Ruby SDK

…and many more

Java client API

User Code

Couchbase Server

CouchbaseClient cb = new CouchbaseClient(listURIs,"aBucket", "letmein");

cb.set("hello", 0, "world");cb.get("hello");

http://www.couchbase.com/develop

Couchbase Java Library (spymemcached)

Page 35: Introduction to couchbase server 20 12012012

35

QUESTIONS?

35

Page 36: Introduction to couchbase server 20 12012012

36

THANK YOU

[email protected]

@DBORKAR

36