Utah PHP Users Group - 2012
Upcoming SlideShare
Loading in...5
×
 

Utah PHP Users Group - 2012

on

  • 1,798 views

Introduction slide deck to Riak using the PHP client.

Introduction slide deck to Riak using the PHP client.

Statistics

Views

Total Views
1,798
Views on SlideShare
1,795
Embed Views
3

Actions

Likes
0
Downloads
2
Comments
2

1 Embed 3

https://twitter.com 3

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Used for moving data around & dealing with failures - without applications noticing.\n\ndue to how data is replicated, there is no SPOF, or master / slave setup.\n\ndue to no SPOF and how replication is done, every node in the cluster looks the same.\n - can read and write from each node\n - turns out to be operationally friendly.\n\n\nAT&T for mHealth is using Riak replication across multiple data centers.\n\n
  • always accepts writes.\n - (will not talk in detail, but you can ask me questions, send me email, or bug me on twitter).\n - causes the need to read repair.\n - eventually consistent. (tough for some people to grok at first).\n - ask me questions, or find me after & we can chat all day long about it.\n
  • \n
  • X = throughput, compute power for MapReduce, storage, lower latency\nData center replication. Focus on disaster survival vs recovery.\nenables us to have local data access no matter where you are.\n\n
  • Basic operations are done over HTTP or a Protocol Buffer interface.\n\ndon’t spend much time here\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • will not talk about in detail, but you can ask questions\n - again, twitter\n\ndon’t spend much time here\n
  • will not talk about in detail, but you can ask questions\n - again, twitter\n\ndon’t spend much time here\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • will not talk about in detail, but you can ask questions\n - again, twitter\n\ndon’t spend much time here\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Utah PHP Users Group - 2012 Utah PHP Users Group - 2012 Presentation Transcript

  • Intro to Riak
  • Randy Secrist @randysecristrsecrist@basho.com
  • _Intro to Riak
  • Riak is a Database
  • Riak is Open Source http://git.io/basho http://git.io/riak http://git.io/riak_core http://git.io/riak_kv
  • Riak is Eventually
  • Eventual ...Consistency
  • CAP• Consistency• Availability• Partitioning
  • BASE• Basically• Available• Soft• State
  • Riak’s Strong Areas• Availability• Partitioning
  • Riak is also ...
  • • Fault-Tolerant• Highly-Available• Geo Distributable, horizontally scaleable• Built for the Web
  • Fault-Tolerant• All nodes participate equally - no SPOF• All data is replicated• Cluster transparently survives ... • node failures • network partitions• Built on Erlang/OTP (designed for FT)
  • Highly-Available• Masterless: Any node can service client requests.• Fallbacks are used when nodes are down.• Always accepts read and write requests.• Per-Request Quorums
  • SCALES
  • Geo Distributable & Horizontally Scalable• Default configuration is in a cluster• Load and data are spread evenly• Add more nodes to get more X• Multi Data Center Replication*
  • Built for the Web• HTTP is default (but not only) interface• Does HTTP/REST well (see Webmachine)• Plays well with HTTP infrastructure - reverse proxy caches, load balancers, web servers.• Suitable for many web and mobile applications.
  • Riak Features
  • Native APIs
  • HTTP
  • Protocol Buffers
  • Client Libraries
  • Erlang
  • Ruby
  • Java
  • Python
  • PHPhttps://github.com/basho/riak-php-client
  • Many more client librarieshttp://wiki.basho.com/Client-Libraries.html
  • Querying• Key Value - get, put, delete • Value is mostly opaque (some metadata)• Secondary Indexes• Map Reduce• Links• Full Text Search (Lucene Style)
  • Storage Backends• Bitcask• LevelDB• Memory• Multi
  • Request Quorums• Every request contacts all replicas of key• N - number of replicas (default 3)• R - read quorum• W - write quorum
  • Hands on!Setting it Up!
  • brew install riak
  • /usr/local/bin/riak start
  • Use ‘join’ command to build a cluster
  • Main Config File etc/app.config
  • Rekonhttps://github.com/basho/rekon curl -s rekon.basho.com | sh or curl -s rekon.basho.com | node=node-addr:port sh
  • PHP Client Demo
  • Connecting to Riakrequire_once(riak-php-client/riak.php);$client = new RiakClient(127.0.0.1, 8098);
  • Buckets$bucket = $client->bucket(friends);
  • Writing Data$person = $bucket->newObject(‘jack’,array( ‘name’ => “Jack Bauer”, ‘age’ => 24, ‘hobbies’ => “Interrogation”));$person->store();
  • Getting Data$jack = $bucket->get(jack);$me = $bucket->get(randy);
  • Riak Objectsforeach ($me->data as $key =>$value) print($key);
  • PHP DocumentationReadme: http://git.io/pk5umAPHP Docs: http://git.io/9YYaKQ
  • s3:// compatible layer http://basho.com/products/riakcs
  • Thank You!
  • References• http://www.infoq.com/articles/cap-twelve-years-later-how-the-rules-have-changed• http://www.odbms.org/blog/2012/08/on-eventual-consistency-an-interview-with-justin-sheehy/• http://pbs.cs.berkeley.edu/#demo• https://github.com/basho/riak-php-client/blob/master/README.md
  • Credits• Slides by Casey Rosenthal• Slides by Bryce Kerley
  • Consistent Hashing & The Ring
  • Consistent Hashing & The Ring• 160-bit integer keyspace 0 2 160/4 2 160/2
  • Consistent Hashing & The Ring• 160-bit integer keyspace• Divided into fixed 0 number of evenly-sized partitions 32 partitions 2 160/4 2 160/2
  • Consistent Hashing & The Ring node 0 node 1• 160-bit integer keyspace node 2• Divided into fixed 0 node 3 number of evenly-sized partitions• Partitions are claimed by 32 partitions 2 160/4 nodes in the cluster 2 160/2
  • Consistent Hashing & The Ring node 0 node 1• 160-bit integer keyspace node 2• Divided into fixed node 3 number of evenly-sized partitions• Partitions are claimed by nodes in the cluster• Replicas go to the N partitions following the key
  • Consistent Hashing & The Ring node 0 node 1• 160-bit integer keyspace node 2• Divided into fixed node 3 number of evenly-sized partitions• Partitions are claimed by nodes in the cluster N=3• Replicas go to the N partitions following the key hash(“utah/uphpu”)
  • Hinted Handoff
  • Hinted Handoff• Node fails X X X X X X X X
  • Hinted Handoff• Node fails X X• Requests go to fallback X X X X X X hash(“utah/uphpu”)
  • Hinted Handoff• Node fails• Requests go to fallback• Node comes back hash(“utah/uphpu”)
  • Hinted Handoff• Node fails• Requests go to fallback• Node comes back• “Handoff” - data returns to recovered node hash(“utah/uphpu”)
  • Hinted Handoff• Node fails• Requests go to fallback• Node comes back• “Handoff” - data returns to recovered node• Normal operations resume hash(“utah/uphpu”)
  • Riak ArchitectureErlang/OTP Runtime
  • Riak ArchitectureErlang/OTP Runtime Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce Riak Core Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce consistent hashing Riak Core Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce consistent hashing membership Riak Core Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce consistent hashing handoff membership Riak Core Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce consistent hashing handoff membership node-liveness Riak Core Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce consistent hashing handoff gossip membership node-liveness Riak Core Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce consistent hashing handoff gossip membership node-liveness buckets Riak Core Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce consistent hashing handoff gossip membership node-liveness buckets Riak Core vnode master Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce consistent hashing handoff gossip membership node-liveness buckets Riak Core vnode master vnodes Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce consistent hashing handoff gossip membership node-liveness buckets Riak Core vnode master vnodes storage backend Riak KV
  • Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce consistent hashing handoff gossip membership node-liveness buckets Riak Core vnode master vnodes JS Runtime storage backend Riak KV