Riak and Ruby

42
basho Riak and Ruby Grant Schofield Developer Advocate Basho Technologies, Inc. Friday, July 9, 2010

description

 

Transcript of Riak and Ruby

Page 1: Riak and Ruby

basho

Riak and RubyGrant Schofield

Developer AdvocateBasho Technologies, Inc.

Friday, July 9, 2010

Page 2: Riak and Ruby

basho

Grant Schofield(@schofield)

basho

Friday, July 9, 2010

Page 3: Riak and Ruby

basho

NoSQL•Web 2.0, Cloud, Enterprise???

•Useful Reference Point

•Not AntiSQL

•Schemaless (Mostly)

•Diverse

•Thoughtful Data (Not just a NoSQL

Friday, July 9, 2010

Page 4: Riak and Ruby

basho

NoSQL Includes...

•Key Value Stores

•Document Databases

•Graphing Databases

•Column Databases

•Schemaless MySQL

Friday, July 9, 2010

Page 5: Riak and Ruby

basho

Prevalent Now

•Memcache???

•Session Data

•Caching Data

•Complements Traditional RDBMS

•Not The Magical Unicorn, but Pony Perhaps

Friday, July 9, 2010

Page 6: Riak and Ruby

basho

Riak•Open Source

•Erlang

•Dynamo and CAP Theorem Influenced

•Advanced Key Value Store

•Web Shaped

•Distributed by Nature

•Ops Obsessed

•A Platform

Friday, July 9, 2010

Page 7: Riak and Ruby

basho

Dynamo Paper•Key Value Store Built By Amazon for

Core Services

•Sacrifice Availability for Consistency

•Consistent Hashing

•Merkle Trees

•Vector Clocks

•Eventually Consistent

Friday, July 9, 2010

Page 8: Riak and Ruby

basho

CAP TheoremConsistency, Availability,

Partition Tolerance

•Dr. Eric Brewer

•At a Given Point You Get Two of the Three

•Riak is Tunable

•Eventual Consistency - Not an Excuse to Lose Data

Friday, July 9, 2010

Page 9: Riak and Ruby

basho

Advanced Key Value Store?

•Not Just PUT and GET Key/Values

•Multiple Interfaces

•Links

•Document Like

•Pluggable Backend

•Map/Reduce

•Distributed

Friday, July 9, 2010

Page 10: Riak and Ruby

basho

Web Shaped

•Biggest Distributed System Ever

•Works Like the Web

•Links

•Talks HTTP Restfully

•Load Balances Just Like Web Stuff

Friday, July 9, 2010

Page 11: Riak and Ruby

basho

Fundamentally Distributed

•Built From The Start

•Masterless

•Homogenous

•Consistent Hashing

•Scales Horizontally

•Fault Tolerant (Hinted Handoff)

Friday, July 9, 2010

Page 12: Riak and Ruby

basho

Consistent Hashing

2160/2

2160/4

node 0

node 1

node 2

node 3

hash(<<"beer">>,<<"dns">>)

Friday, July 9, 2010

Page 13: Riak and Ruby

basho

N, R, and W•N = Number of Replicas

•R = Number of Replicas Needed for a Read

•W = Number of Replicas Needed for a Write

•DW = Number of Replicas Needed for a Durable Write

•N Configurable Per Bucket

•R and W Configurable Per Request

Friday, July 9, 2010

Page 14: Riak and Ruby

basho

R Valueget(<<"beer">>,<<"dnr">>,

R=2)

{ok, Object}(N=3)

X

Friday, July 9, 2010

Page 15: Riak and Ruby

basho

W Valueput(<<"beer">>,<<"dnr">>,

W=2)

ok(N=3)

X

Friday, July 9, 2010

Page 16: Riak and Ruby

basho

N=10, R/W = 2get/put("beer", "dnr",

R/W=2)

{ok, Object}

(N=10)

X

XXX

X

XX

X

Friday, July 9, 2010

Page 17: Riak and Ruby

basho

Riak from CurlPutting Data In

Friday, July 9, 2010

Page 18: Riak and Ruby

basho

Taking Data Out

Friday, July 9, 2010

Page 19: Riak and Ruby

basho

Deleting The Data

Friday, July 9, 2010

Page 20: Riak and Ruby

basho

Finally, Ruby Stuff

•Sean Cribbs - RDRC Training

•riak-client - basic client

•ripple - associations, ActiveModel

•Really Elegant Code

Friday, July 9, 2010

Page 21: Riak and Ruby

basho

riak-clientgem install riak-client

Friday, July 9, 2010

Page 22: Riak and Ruby

basho

riak-clientget the data

Friday, July 9, 2010

Page 23: Riak and Ruby

basho

riak-clientmoar datas

Friday, July 9, 2010

Page 24: Riak and Ruby

basho

riak clientgot beer

Friday, July 9, 2010

Page 25: Riak and Ruby

basho

riak-clientwhy yes, I do

Friday, July 9, 2010

Page 26: Riak and Ruby

basho

Link Walkinghttp://localhost:8098/riak/beers/dnr/bars,_,1

http://localhost:8098/riak/bars/blue_note/beers,tap,1

http://localhost:8098/riak/areas/midtown//bars,tap,_/beers,_,1

Friday, July 9, 2010

Page 27: Riak and Ruby

basho

riak-clientfind me a dnr!

Friday, July 9, 2010

Page 28: Riak and Ruby

basho

riak-clientwhat does the Fry have on tap?

Friday, July 9, 2010

Page 29: Riak and Ruby

basho

riak-clientin a bottle?

Friday, July 9, 2010

Page 30: Riak and Ruby

basho

riak-clientok, via ruby

Friday, July 9, 2010

Page 31: Riak and Ruby

basho

riak clientvia ruby with map reduce

Friday, July 9, 2010

Page 32: Riak and Ruby

basho

riak-clientmap

Friday, July 9, 2010

Page 33: Riak and Ruby

basho

riak-clientmap and reduce

Friday, July 9, 2010

Page 34: Riak and Ruby

basho

ripplegem install ripple

Friday, July 9, 2010

Page 35: Riak and Ruby

basho

schema design

peoplepeopletweetstweets

riak_20100705riak_20100705

riak_20100704riak_20100704

nosql_20100705nosql_20100705

mongodb_20100705mongodb_20100705

Friday, July 9, 2010

Page 36: Riak and Ruby

bashoFriday, July 9, 2010

Page 37: Riak and Ruby

bashoFriday, July 9, 2010

Page 38: Riak and Ruby

basho

A Model

Friday, July 9, 2010

Page 39: Riak and Ruby

basho

Other Features

Friday, July 9, 2010

Page 40: Riak and Ruby

basho

Riak as a Platform

Friday, July 9, 2010

Page 41: Riak and Ruby

basho

What’s Coming

Friday, July 9, 2010

Page 42: Riak and Ruby

basho

THANKS!http://[email protected]

freenode #riak

Friday, July 9, 2010