Introduction à Couchbase Server 2.0

38

description

Introduction à Couchbase Server 2.0. Tugdual Grall TechnicalEvangelist @ tgrall. {“about” : “me”}. Tugdual “Tug” Grall Couchbase Technical Evangelist eXo CTO Oracle Developer/Product Manager Mainly Java/ SOA Developer in consulting firms. Web @ tgrall http://blog.grallandco.com - PowerPoint PPT Presentation

Transcript of Introduction à Couchbase Server 2.0

Page 1: Introduction  à Couchbase Server 2.0
Page 2: Introduction  à Couchbase Server 2.0

Introduction àCouchbase Server 2.0

Tugdual GrallTechnicalEvangelist

@tgrall

Page 3: Introduction  à Couchbase Server 2.0

{“about” : “me”}

Tugdual “Tug” Grall• Couchbase

• Technical Evangelist• eXo

• CTO• Oracle

• Developer/Product Manager• Mainly Java/SOA

• Developer in consulting firms

• Web• @tgrall• http://blog.grallandco.com• Tgrall

• NantesJUG co-founder

• Pet Project :• http://www.resultri.com

Page 4: Introduction  à Couchbase Server 2.0

Agenda

1. Introduction to Couchbase Server

2. Cluster Management

3. Operation and Document Design

4. Introduction to Views and Queries

5. Cross Data Center Replication

6. Q&A

Couchbase Developer Day Paris is this Friday! http://couchbase.com/events

Page 5: Introduction  à Couchbase Server 2.0

Couchbase Server 2.0

Page 6: Introduction  à Couchbase Server 2.0

Couchbase ServerNoSQL Document Database

Page 7: Introduction  à Couchbase Server 2.0

Couchbase Open Source Project

• Leading NoSQL database project focused on distributed database technology and surrounding ecosystem

• Supports both key-value and document-oriented use cases

• All components are available under the Apache 2.0 Public License

• Obtained as packaged software in both enterprise and community editions.

Couchbase Open Source Project

Page 8: Introduction  à Couchbase Server 2.0

Easy Scalabili

ty

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.

JSONJSONJSON

JSONJSON

PERFORMANCE

Flexible Data Model

JSON document model with no fixed schema.

Couchbase Server

Page 9: Introduction  à Couchbase Server 2.0

New in 2.0

JSON support Indexing and Querying

Cross data center replicationIncremental Map Reduce

JSONJSONJSON

JSONJSON

Page 10: Introduction  à Couchbase Server 2.0

Hea

rtbe

at

Proc

ess

mon

itor

Glo

bal s

ingl

eton

sup

ervi

sor

Confi

gura

tion

man

ager

on each node

Reba

lanc

e or

ches

trat

or

Nod

e he

alth

mon

itor

one per cluster

vBuc

ket s

tate

and

repl

icati

on m

anag

er

httpR

EST m

anagem

ent

API/W

eb U

I

HTTP8091

Erlang port mapper4369

Distributed Erlang21100 - 21199

Erlang/OTP

storage interface

Couchbase EP Engine

11210Memcapable 2.0

Moxi

11211Memcapable 1.0

Memcached

New Persistence Layer

8092Query API

Query

Eng

ine

Data Manager Cluster Manager

Couchbase Server 2.0 Architecture

Page 11: Introduction  à Couchbase Server 2.0

New Persistence Layer

storage interface

Couchbase EP Engine

11210Memcapable 2.0

Moxi

11211Memcapable 1.0

Object-level Cache

Disk Persistence

8092Query API

Query

Eng

ine

HTTP8091

Erlang port mapper4369

Distributed Erlang21100 - 21199

Hea

rtbe

at

Proc

ess

mon

itor

Glo

bal s

ingl

eton

sup

ervi

sor

Confi

gura

tion

man

ager

on each node

Reba

lanc

e or

ches

trat

or

Nod

e he

alth

mon

itor

one per cluster

vBuc

ket s

tate

and

repl

icati

on m

anag

er

http

REST m

anagem

ent

API/W

eb U

IErlang/OTP

Server/Cluster Management & Communication

(Erlang)

RAM Cache, Indexing & Persistence

Management(C & V8)

The Unreasonable Effectiveness of C by Damien Katz

Couchbase Server 2.0 Architecture

Page 12: Introduction  à Couchbase Server 2.0

33 2

Single node - Couchbase Write Operation

Managed Cache

Dis

k Q

ueue

Disk

Replication Queue

App Server

Couchbase Server Node

Doc 1Doc 1

Doc 1

To other node

Page 13: Introduction  à Couchbase Server 2.0

GET

Doc

1

33 2

Single node - Couchbase Read Operation

Dis

k Q

ueue

Replication Queue

App Server

Doc 1

Doc 1Doc 1

Managed Cache

Disk

To other node

Couchbase Server Node

Page 14: Introduction  à Couchbase Server 2.0

COUCHBASE SERVER CLUSTER

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 15: Introduction  à Couchbase Server 2.0

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 16: Introduction  à Couchbase Server 2.0

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 17: Introduction  à Couchbase Server 2.0

Demo Time

Page 18: Introduction  à Couchbase Server 2.0

Operation & Document Design

Page 19: Introduction  à Couchbase Server 2.0

Basic Store & Retrieve Operations

• get(key)Retrieve a document

• set(key, value)Store a document or replace if it exists

• add(key, value)Store a document and fail if it exists

• replace(key, value)Replace a document and fail if it does not exist

Page 20: Introduction  à Couchbase Server 2.0

Lots of other Operations

• Atomic Counters (increment, decrement)

• Append/Prepend

• CAS (Compare and Set) Optimistic Locking

• “Get with Lock” Write Lock on Objects

• Bulk Operations Saves network overhead

• Stats

• View operations

Page 21: Introduction  à Couchbase Server 2.0

Couchbase 2.0 Bonus Points: JSON

• JSON is a lightweight format to represent document structure in a language-independent manner.

• If JSON documents are stored, the View engine can be used.

• Allows to build secondary indexes on your datasets.

• Makes it possible to ask questions like“Give me all user documents by lastname”.

Page 22: Introduction  à Couchbase Server 2.0

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”}

JSONJSON

JSON JSON

Page 23: Introduction  à Couchbase Server 2.0

Aggregate View of Data

http://martinfowler.com/bliki/AggregateOrientedDatabase.html

Page 24: Introduction  à Couchbase Server 2.0

Store and Retrieve Aggregates

• Easier to Distribute Data• More Flexibility• Reduced Latency

order::1001{uid: ji22jd,customer: Ann,line_items: [

{ sku: 0321293533, quan: 3, unit_price: 48.0 },{ sku: 0321601912, quan: 1, unit_price: 39.0 },{ sku: 0131495054, quan: 1, unit_price: 51.0 }

],payment: { type: Amex, expiry: 04/2001,

last5: 12345 }}

Page 25: Introduction  à Couchbase Server 2.0

Demo Time

Page 26: Introduction  à Couchbase Server 2.0

Official SDKs

Community SDKs

www.couchbase.com/develop

PythonRuby

Go Clojure

Page 27: Introduction  à Couchbase Server 2.0

Indexing and Querying

Page 28: Introduction  à Couchbase Server 2.0

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

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

Page 29: Introduction  à Couchbase Server 2.0

COUCHBASE SERVER CLUSTER

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 30: Introduction  à Couchbase Server 2.0

Demo Time

Page 31: Introduction  à Couchbase Server 2.0

Cross Data Center Replication(XDCR)

Page 32: Introduction  à Couchbase Server 2.0

Cross Data Center Replication – The basics

• Replicate your Couchbase data across clusters

• Clusters may be spread across geos

• Configured on a per-bucket (per-database) 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 33: Introduction  à Couchbase Server 2.0

Cross Data Center Replication (XDCR)COUCHBASE SERVER CLUSTER

USACTIVE

Doc

Doc 2

SERVER 1

Doc 9

SERVER 2 SERVER 3

RAM

Doc Doc Doc

ACTIVE

Doc

Doc

Doc RAM

ACTIVE

Doc

Doc

DocRAM

DISK

Doc Doc Doc

DISK

Doc Doc Doc

DISK

COUCHBASE SERVER CLUSTEREMEA

ACTIVE

Doc

Doc 2

SERVER 1

Doc 9

SERVER 2 SERVER 3

RAM

Doc Doc Doc

ACTIVE

Doc

Doc

Doc RAM

ACTIVE

Doc

Doc

DocRAM

DISK

Doc Doc Doc

DISK

Doc Doc Doc

DISK

Page 34: Introduction  à Couchbase Server 2.0

Couchbase Handles Real World Scale

Page 35: Introduction  à Couchbase Server 2.0

Q & A

Page 36: Introduction  à Couchbase Server 2.0

• Couchbase DeveloperDays Paris This Friday !

Presentations & Labs

Information

• http://www.couchbase.com/events

Use the promo code TUG

Page 37: Introduction  à Couchbase Server 2.0

Thank [email protected]

@tgrall

Get Couchbase Server at http://www.couchbase.com/download

Page 38: Introduction  à Couchbase Server 2.0