CouchConf Israel Couchbase in Production 24x7

28
1 Couchbase Server 2.0 in Production

Transcript of CouchConf Israel Couchbase in Production 24x7

Page 1: CouchConf Israel Couchbase in Production 24x7

1

Couchbase Server 2.0 in Production

Page 2: CouchConf Israel Couchbase in Production 24x7

2

Couchbase Server 2.0: Overview

• Membase + CouchDB• Managed memory caching layer = super high performance• Clustering and online data redistribution (Rebalancing)• Indexing and Querying via JSON Map-Reduce• New SDK’s and client libraries

• Developer Preview available at:• http://www.couchbase.com/downloads

=Simple. Fast. Elastic.

Page 3: CouchConf Israel Couchbase in Production 24x7

3

www.facebook.com/farm_town_wars

Web Servers

Load Balancer

Couchbase Servers

Let’s build a social game…

Page 4: CouchConf Israel Couchbase in Production 24x7

4

COUCHBASE SERVER 2.0 IN PRODUCTION: DEV/OPS LIFECYCLE

Initial Setup

View Development Sizing

Client setup

Monitor Grow

Backup/Restore

Upgrade

Deploy

MaintainFailures

Test

Page 5: CouchConf Israel Couchbase in Production 24x7

5

Couchbase Server 2.0 in production: Initial Setup

Extremely easy to get up and running:

• RPM/deb/OSX/exe installation

• Simple Web UI and setup wizard

Page 6: CouchConf Israel Couchbase in Production 24x7

6

Data and Indexes

• Data goes “in and out” via the Memcached protocol

• Queries/indexes are created and accessed via an HTTP protocol

• Both are available separately, Couchbase-provided SDK’s will expose a single API to the developer and abstract the actual traffic

Page 7: CouchConf Israel Couchbase in Production 24x7

7

Data and Indexes

Example JSON Document:

{

"_id": "Keith4540",

"jsonType": "player",

"name": "Keith4540",

"level": 4,

}

Example view:

function (doc) {

if (doc.jsonType == "player"){

emit(["Level", doc.level], doc._id);}

}

+

=Secondary index of players, by level

(Demo)

Page 8: CouchConf Israel Couchbase in Production 24x7

8

Data and Indexes

• Indexes/views are based on incremental map-reduce:• Indexes are updated with incremental changes (not

batch)

• View processing is done per-vbucket:• Parallel processing on subset of data• Couchbase provides scatter-gather aggregation

Page 9: CouchConf Israel Couchbase in Production 24x7

9

Data and Indexes

• Views are “developed” off of a random (or specific) sampling of the overall dataset and then deployed• Faster• Less load on system

• Updated views can be applied without rescanning entire dataset

Page 10: CouchConf Israel Couchbase in Production 24x7

10

Couchbase Client SDKs

Java Client SDK

.Net SDK

PHP SDK

Ruby SDK

Python SDK

Spy memcachedConnection

HTTP couchDBconnection

Java client API

User Code

Couchbase Server

CouchbaseClient cb = new CouchbaseClient(listURIs,"aBucket", "letmein");// this is all the same as beforecb.set("hello", 0, "world");cb.get("hello");Map<String, Object> manyThings =cb.getBulk(Collection<String> keys);/* accessing a view View view = cb.getView("design_document", "my_view");Query query = new Query();query.getRange("abegin", "theend");

Page 11: CouchConf Israel Couchbase in Production 24x7

11

COUCHBASE SERVER 2.0 IN PRODUCTION: DEV/OPS LIFECYCLE

Sizing

Client setup

Deploy

Page 12: CouchConf Israel Couchbase in Production 24x7

12

Couchbase Server 2.0 in production: Sizing

Sizing Question: How many nodes do I need?

Considerations:RAMDiskNetworkData Safety

Page 13: CouchConf Israel Couchbase in Production 24x7

13

Sizing

Sizing Question: How many nodes do I need?

Considerations:RAM• Metadata• Working set• Buffer/overhead

Active+Replica

Page 14: CouchConf Israel Couchbase in Production 24x7

14

Sizing

500,000 Documents to begin with:-20 bytes in length-average Document size of 2k-metadata of about 150 bytes per key

~1Gb to store active data, an extra 1Gb to store replica data

Adding in some headroom: Give 3GB RAM to Couchbase to start and grow with

=

Page 15: CouchConf Israel Couchbase in Production 24x7

15

Sizing

Sizing Question: How many nodes do I need?

Considerations:Disk:• Sustained write rate• Index generation (space and IO)• Append-only B-Tree• Compaction• Rebalance capacity

Page 16: CouchConf Israel Couchbase in Production 24x7

16

Sizing

Sizing Question: How many nodes do I need?

Considerations:Network:• Client traffic• Replication• Rebalancing

Page 17: CouchConf Israel Couchbase in Production 24x7

17

Sizing

Sizing Question: How many nodes do I need?

Considerations:Data Safety

1 node = single point of failure (bad)2 nodes = 1 replica copy (better)3+ nodes = 1 replica copy AND data/load distribution

Page 18: CouchConf Israel Couchbase in Production 24x7

18

Sizing

Sizing Question: How many nodes do I need?

Considerations:RAMDisk NetworkData Safety

Page 19: CouchConf Israel Couchbase in Production 24x7

19

Farm Town Wars App Code

Ap

plic

atio

n s

erv

er

Co

uch

ba

se

Se

rve

r

Couchbase JavaClient library

Query API

Couchbase

11210

(“smart”) library

Farm Town Wars App Code

Ap

plic

atio

n s

erv

er

Co

uch

ba

se

Se

rve

r

Couchbase PHP Client Library

Moxi (Couchbase proxy)

Query API

Couchbase

11210

Client-side Moxi

OR80928092

Client-side Deployment

Page 20: CouchConf Israel Couchbase in Production 24x7

20

COUCHBASE SERVER 2.0 IN PRODUCTION: DEV/OPS LIFECYCLE

Monitor Grow

Backup/Restore

UpgradeMaintainFailures

Page 21: CouchConf Israel Couchbase in Production 24x7

21

Monitoring

IMMENSE amount of information available

-Real-time traffic graphs

-REST API accessible

-Per bucket, per node and aggregate statistics

-Application and inter-node traffic

-RAM <-> Disk

-Inter-system timing

Page 22: CouchConf Israel Couchbase in Production 24x7

22

Page 23: CouchConf Israel Couchbase in Production 24x7

23

Growth

Going from 1 hundred users to 2 million users…

– RAM usage is growing:• Ejecting data to and fetching data from disk

• Resident item ratios decreasing – might impact failover

• Cache miss ratio increases

– Disk write queue grows higher than usual

Need to add a few more nodes...

Now we have more RAM and more disk throughput without any downtime

(Demo)

Page 24: CouchConf Israel Couchbase in Production 24x7

24

General Maintenance

• Persistence is using CouchDB technology:– Append-only B-tree

– Reliability and data integrity

– Constantly growing on-disk files

• Compaction is the answer:– Automatic

– “Fragmentation” data

– Scheduled compaction

– Partial compaction via per-vbucket database (saves disk space and time)

Page 25: CouchConf Israel Couchbase in Production 24x7

25

• Backup/Restore:– Backup is as simple as a file-level copy (thanks CouchDB!)

– Server will automatically “warmup” from disk files upon reboot

• Upgrade:– Add nodes of new version, rebalance…

– Remove nodes of old version, rebalance…

– Done!

– No disruption

– Upgrade from existing Membase 1.7 installations to

Couchbase 2.0

General Maintenance

Page 26: CouchConf Israel Couchbase in Production 24x7

26

Failures

• Failures happen:

– Hardware

– Network– Bugs

• Failover to replica data for immediate access

• Remove and rebalance “malfunctioning” node

(Demo)

Page 27: CouchConf Israel Couchbase in Production 24x7

27

COUCHBASE SERVER 2.0 IN PRODUCTION: DEV/OPS LIFECYCLE

Initial Setup

View Development Sizing

Client setup

Monitor Grow

Backup/Restore

Upgrade

Deploy

MaintainFailures

Test

Page 28: CouchConf Israel Couchbase in Production 24x7

28

THANK YOU!

Q&A