Your SlideShare is downloading. ×
0
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...
Highly-Available• Masterless: Any node can service client  requests.• Fallbacks are used when nodes are down.• Always acce...
SCALES
Geo Distributable & Horizontally Scalable• Default configuration is in a cluster• Load and data are spread evenly• Add more...
Built for the Web• HTTP is default (but not only) interface• Does HTTP/REST well (see Webmachine)• Plays well with HTTP in...
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• Ful...
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 - wri...
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’ => “Interro...
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...
Credits•   Slides by Casey Rosenthal•   Slides by Bryce Kerley
Consistent Hashing &      The Ring
Consistent Hashing &      The Ring•   160-bit integer keyspace                                 0                          ...
Consistent Hashing &      The Ring•   160-bit integer keyspace•   Divided into fixed                   0    number of evenl...
Consistent Hashing &      The Ring                                             node 0                                     ...
Consistent Hashing &      The Ring                  node 0                                node 1•   160-bit integer keyspa...
Consistent Hashing &      The Ring                              node 0                                            node 1• ...
Hinted Handoff
Hinted Handoff•   Node fails               X                     X                                 X                 X    ...
Hinted Handoff•   Node fails                                  X                                  X•   Requests go to fallb...
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 nod...
Hinted Handoff•   Node fails•   Requests go to fallback•   Node comes back•   “Handoff” - data returns    to recovered nod...
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...
Riak ArchitectureErlang/OTP Runtime      Client APIs    HTTP               Protocol Buffers                            Erl...
Riak ArchitectureErlang/OTP Runtime      Client APIs      HTTP               Protocol Buffers                             ...
Riak ArchitectureErlang/OTP Runtime      Client APIs      HTTP               Protocol Buffers                             ...
Riak ArchitectureErlang/OTP Runtime      Client APIs      HTTP               Protocol Buffers                             ...
Riak ArchitectureErlang/OTP Runtime      Client APIs        HTTP                 Protocol Buffers                         ...
Riak ArchitectureErlang/OTP Runtime      Client APIs        HTTP                 Protocol Buffers                         ...
Riak ArchitectureErlang/OTP Runtime      Client APIs        HTTP                  Protocol Buffers                        ...
Riak ArchitectureErlang/OTP Runtime      Client APIs       HTTP               Protocol Buffers                            ...
Riak ArchitectureErlang/OTP Runtime      Client APIs       HTTP               Protocol Buffers                            ...
Riak ArchitectureErlang/OTP Runtime      Client APIs      HTTP               Protocol Buffers                             ...
Riak ArchitectureErlang/OTP Runtime      Client APIs          HTTP                Protocol Buffers                        ...
Riak ArchitectureErlang/OTP Runtime      Client APIs          HTTP                Protocol Buffers                        ...
Riak ArchitectureErlang/OTP Runtime      Client APIs          HTTP                Protocol Buffers                        ...
Riak ArchitectureErlang/OTP Runtime      Client APIs          HTTP                Protocol Buffers                        ...
Utah PHP Users Group - 2012
Utah PHP Users Group - 2012
Upcoming SlideShare
Loading in...5
×

Utah PHP Users Group - 2012

1,755

Published on

Introduction slide deck to Riak using the PHP client.

Published in: Technology
2 Comments
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total Views
1,755
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
2
Likes
0
Embeds 0
No embeds

No notes for slide
  • \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
  • Transcript of "Utah PHP Users Group - 2012"

    1. 1. Intro to Riak
    2. 2. Randy Secrist @randysecristrsecrist@basho.com
    3. 3. _Intro to Riak
    4. 4. Riak is a Database
    5. 5. Riak is Open Source http://git.io/basho http://git.io/riak http://git.io/riak_core http://git.io/riak_kv
    6. 6. Riak is Eventually
    7. 7. Eventual ...Consistency
    8. 8. CAP• Consistency• Availability• Partitioning
    9. 9. BASE• Basically• Available• Soft• State
    10. 10. Riak’s Strong Areas• Availability• Partitioning
    11. 11. Riak is also ...
    12. 12. • Fault-Tolerant• Highly-Available• Geo Distributable, horizontally scaleable• Built for the Web
    13. 13. 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)
    14. 14. 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
    15. 15. SCALES
    16. 16. 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*
    17. 17. 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.
    18. 18. Riak Features
    19. 19. Native APIs
    20. 20. HTTP
    21. 21. Protocol Buffers
    22. 22. Client Libraries
    23. 23. Erlang
    24. 24. Ruby
    25. 25. Java
    26. 26. Python
    27. 27. PHPhttps://github.com/basho/riak-php-client
    28. 28. Many more client librarieshttp://wiki.basho.com/Client-Libraries.html
    29. 29. Querying• Key Value - get, put, delete • Value is mostly opaque (some metadata)• Secondary Indexes• Map Reduce• Links• Full Text Search (Lucene Style)
    30. 30. Storage Backends• Bitcask• LevelDB• Memory• Multi
    31. 31. Request Quorums• Every request contacts all replicas of key• N - number of replicas (default 3)• R - read quorum• W - write quorum
    32. 32. Hands on!Setting it Up!
    33. 33. brew install riak
    34. 34. /usr/local/bin/riak start
    35. 35. Use ‘join’ command to build a cluster
    36. 36. Main Config File etc/app.config
    37. 37. Rekonhttps://github.com/basho/rekon curl -s rekon.basho.com | sh or curl -s rekon.basho.com | node=node-addr:port sh
    38. 38. PHP Client Demo
    39. 39. Connecting to Riakrequire_once(riak-php-client/riak.php);$client = new RiakClient(127.0.0.1, 8098);
    40. 40. Buckets$bucket = $client->bucket(friends);
    41. 41. Writing Data$person = $bucket->newObject(‘jack’,array( ‘name’ => “Jack Bauer”, ‘age’ => 24, ‘hobbies’ => “Interrogation”));$person->store();
    42. 42. Getting Data$jack = $bucket->get(jack);$me = $bucket->get(randy);
    43. 43. Riak Objectsforeach ($me->data as $key =>$value) print($key);
    44. 44. PHP DocumentationReadme: http://git.io/pk5umAPHP Docs: http://git.io/9YYaKQ
    45. 45. s3:// compatible layer http://basho.com/products/riakcs
    46. 46. Thank You!
    47. 47. 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
    48. 48. Credits• Slides by Casey Rosenthal• Slides by Bryce Kerley
    49. 49. Consistent Hashing & The Ring
    50. 50. Consistent Hashing & The Ring• 160-bit integer keyspace 0 2 160/4 2 160/2
    51. 51. 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
    52. 52. 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
    53. 53. 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
    54. 54. 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”)
    55. 55. Hinted Handoff
    56. 56. Hinted Handoff• Node fails X X X X X X X X
    57. 57. Hinted Handoff• Node fails X X• Requests go to fallback X X X X X X hash(“utah/uphpu”)
    58. 58. Hinted Handoff• Node fails• Requests go to fallback• Node comes back hash(“utah/uphpu”)
    59. 59. Hinted Handoff• Node fails• Requests go to fallback• Node comes back• “Handoff” - data returns to recovered node hash(“utah/uphpu”)
    60. 60. Hinted Handoff• Node fails• Requests go to fallback• Node comes back• “Handoff” - data returns to recovered node• Normal operations resume hash(“utah/uphpu”)
    61. 61. Riak ArchitectureErlang/OTP Runtime
    62. 62. Riak ArchitectureErlang/OTP Runtime Riak KV
    63. 63. Riak ArchitectureErlang/OTP Runtime Client APIs Riak KV
    64. 64. Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Riak KV
    65. 65. Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Riak KV
    66. 66. Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Riak KV
    67. 67. Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination Riak KV
    68. 68. Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce Riak KV
    69. 69. Riak ArchitectureErlang/OTP Runtime Client APIs HTTP Protocol Buffers Erlang local client Request Coordination get put delete map-reduce Riak Core Riak KV
    70. 70. 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
    71. 71. 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
    72. 72. 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
    73. 73. 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
    74. 74. 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
    75. 75. 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
    76. 76. 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
    77. 77. 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
    78. 78. 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
    79. 79. 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
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×