membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A...

37
CS227 CS227 - - Silvia Silvia Zuffi Zuffi - - Sunil Mallya Sunil Mallya Slides credits: official Slides credits: official membase meetings membase meetings

Transcript of membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A...

Page 1: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

CS227CS227-- Silvia Silvia ZuffiZuffi

-- Sunil MallyaSunil Mallya

Slides credits: official Slides credits: official membase meetings membase meetings

Page 2: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

2

Schedule

• Overview silvia

• History silvia

• Data Model silvia

• Architecture sunil

• Transaction support sunil

• Case studies silvia

Page 3: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Overview, history and data model

Page 4: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

3

Overview: what is Membase?

• A key-value distributed database optimized for storing data behind web applications

• Simple - Fast - Elastic (by design)

Page 5: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

3

Overview: before

Application Scales OutJust add more commodity web servers

Page 6: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

3

Overview: with Membase

Membase Servers

Web application server

Application user

DATA CENTER ADMINISTRATOR CONSOLE

Page 7: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

3

Overview: after

Application Scales OutJust add more commodity web servers

Database Scales OutJust add more commodity data servers

Page 8: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

4

History

• Membase was developed by NorthScale, founded by several leaders of the memcached project

• June 2010: NorthScale, and project co-sponsors Zyngaand NHN create a new project (membase.org).

• February 8, 2011, Membase merged with CouchOne.Themerged project will be known as Couchbase

Page 9: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

4

History

QuickTime™ e undecompressore

sono necessari per visualizzare quest'immagine.

James Phillips, senior Vice President

Page 10: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

5

History

• Initial release March 2010

• Stable release 1.6.4.1 28 Dec 2010

Page 11: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

6

Data Model

•Key-value

•Motivation: applications with natural keys to access data (es.: username.birthday)

Page 12: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

7

Key-value

KeyValue

Data types:Byte[]

Google protobufThriftAvro

“Any customer can have a car painted any colour that he wants so long as it is black.”

Page 13: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

8

Operators and Programming Languages

• GET/SET

– getl: get with an expiration time

• Increment/Decrement

• Append/Prepend

• Practically every language and application framework is supported (“memcapable”)

• Data manager: written in C, C++• Cluster manager: Erlang/OTP

Page 14: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

9

Transactions

• Based on CAS operations

• Compare and Swap

• special instruction that atomically compares the content of a memory location

User 1

Fail!

User 2Success

Page 15: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Architecture and transaction support

Page 16: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

10

What is the problem being solved ?

• Highly interactive web apps

• Small amount of data

• Why doesn’t the traditional architecture work ?

• Is nosql “DB” really a DB ?

• Can a Database do what a nosql-db does?– If yes ? Why not use a database

– What is it that is really different ?• De Normalized data

Page 17: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

10

Membase - A practical path to “NoSQL” adoption

Page 18: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

10

Physical Structures

• CA type system: scale linearly and always maintain consistency

• Clustering based on Erlang OTP

• Things are persistent, Data is written to Disk.

Page 19: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

15

Elasticity

Page 20: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

16

Elasticity

Page 21: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

14

Elasticity

Page 22: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

11

Architecture

moxi

11211 11210

memcachedprotocol listener/sender

membase storage engine

engine interface

memcapable 1.0 memcapable 2.0

httpR

ES

T m

anag

emen

t AP

I/Web

UI

Hea

rtbe

at

Pro

cess

mon

itor

Glo

bal s

ingl

eton

sup

ervi

sor

Con

figur

atio

n m

anag

er

on each node

Erlang/OTP

Reb

alan

ce o

rche

stra

tor

Nod

e he

alth

mon

itor

one per cluster

vBuc

ket s

tate

and

rep

licat

ion

man

ager

HTTP distributed erlangerlang port mapperDATA MANAGER

CLUSTER MANAGER

Page 23: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

12

vBuckets

QuickTime™ e undecompressore

sono necessari per visualizzare quest'immagine.

Any given vbucket will be in one of the following states on any given server:

http://blog.membase.com/scaling-memcached-vbuckets

Page 24: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

13

vBuckets mappings

Page 25: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

25

TAP

• A generic, scalable method of streaming mutations from a given server– As data operations arrive, they can be sent to arbitrary TAP

receivers

• Leverages the existing memcached engine interface, and the non-blocking IO interfaces to send data

• Three modes of operation

Page 26: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

14

Replication & Failover

•Multi-model replication support• Peer-to-peer replication support with underlying architecture supporting master-slave replication

•Configurable replication count• Balance resource utilization with availability requirements

•High-speed failoverFast failover to replicated items based upon request

Page 27: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Case sudies

Page 28: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Where does Membase fit?

• Online applications with a lot of users

• Applications with growing datasets which need quick access

Page 29: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Users

• Who uses Membase?

Page 30: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Users: zynga

Social game leader – FarmVille, Mafia Wars, Café WorldOver 230 million monthly users

• Membase Serveris the 500,000 ops-per-second database behind FarmVille and CaféWorld

Page 31: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Case Study: Ad targeting

Aol website

Target users based on what they have bought and the sites they have visited

Target users based on registration information

Page 32: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Case study: sharing network

Page 33: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Case study: sharing network

450/momillion

consumers

~850thousand sites

50+social channels

Page 34: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Case study: targeting

Log FilesSearch Keywords

Page Views

Sharing Behavior

HDFS

Map/Reduce

Content Analysis

Taxonomy

Ad Server

User Membase22

Page 35: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Case Study: Ad targeting

• Data management challenges :

• to analyze billions of user-related events, presented as a mix of structured and unstructured data, to infer demographic, psychographic and behavioral characteristics (“cookie profiles”)

• make hundreds of millions of cookie profiles available to their AD targeting platform fast

• to keep the user profiles updated

Page 36: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Case Study: Ad targeting

Page 37: membase - cs.brown.educs.brown.edu/courses/cs227/archives/2011/slides/mar14-membase.pdf• A key-value distributed database optimized for storing data behind web applications • Simple

Thanks