Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Like this? Share it with your network

Share

Masterless Distributed Computing with Riak Core - EUC 2010

on

  • 5,407 views

Riak Core--an open-source Erlang library created by Basho Technologies that powers Riak KV and Riak Search--allows developers to build distributed, scalable, failure-tolerant applications based on a ...

Riak Core--an open-source Erlang library created by Basho Technologies that powers Riak KV and Riak Search--allows developers to build distributed, scalable, failure-tolerant applications based on a generalized version of Amazon's Dynamo architecture. In this talk, Rusty will explain why Riak Core was built, discuss what problems it solves and how it works, and walk through the steps to using Riak Core in an Erlang application.

Statistics

Views

Total Views
5,407
Views on SlideShare
5,404
Embed Views
3

Actions

Likes
15
Downloads
142
Comments
0

1 Embed 3

http://paper.li 3

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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

Masterless Distributed Computing with Riak Core - EUC 2010 Presentation Transcript

  • 1. Masterless Distributed Computing with Riak Core Erlang User Conference Stockholm, Sweden · November 2010 Rusty Klophaus (@rklophaus) Basho Technologies Monday, November 22, 2010
  • 2. Basho Technologies About Basho Technologies • Offices in: • Cambridge, Massachusetts • San Francisco, California • Distributed company • ~20 people • Riak KV and Riak Search (both Open Source) • SLA-based Support and Enterprise Software ($) • Other Open Source Erlang developed by Basho: • Webmachine, Rebar, Bitcask, Erlang_JS, Basho Bench 2 Monday, November 22, 2010
  • 3. Riak KV and Riak Search Riak KV Key/Value Datastore Map/Reduce, Lightweight Data Relations, Client APIs Riak Search Full-text search and indexing engine Near Realtime Indexing, Riak KV Integration, Solr Support. Common Properties Both are distributed, scalable, failure-tolerant applications. Both based on Amazon’s Dynamo Architecture. 3 Monday, November 22, 2010
  • 4. The Common Parts are called Riak Core Riak Riak Riak KV Core Search Monday, November 22, 2010
  • 5. The Common Parts are called Riak Core Riak Riak Riak KV Core Search Distribution / Scaling / Failure-Tolerance Code Monday, November 22, 2010
  • 6. Riak Core is an Open Source Erlang library that helps you build distributed, scalable, failure-tolerant applications using a Dynamo-style architecture. 6 Monday, November 22, 2010
  • 7. “We Generalized the Dynamo Architecture and Open-Sourced the Bits.” 7 Monday, November 22, 2010
  • 8. What Areas are Covered? Amazon’s Dynamo Paper highlighted to show parts covered in Riak Core. Monday, November 22, 2010
  • 9. Distributed, scalable, failure-tolerant. 9 Monday, November 22, 2010
  • 10. Distributed, scalable, failure-tolerant. No central coordinator. Easy to setup/operate. 10 Monday, November 22, 2010
  • 11. Distributed, scalable, failure-tolerant. Horizontally scalable; add commodity hardware to get more X. 11 Monday, November 22, 2010
  • 12. Distributed, scalable, failure-tolerant. Always available. No single point of failure. Self-healing. 12 Monday, November 22, 2010
  • 13. Wait, doesn’t *Erlang* let you build distributed, scalable, failure-tolerant applications? 13 Monday, November 22, 2010
  • 14. Erlang makes it easy to connect the components of your application. Client Service A Service B Service C Queue E Resource D Monday, November 22, 2010
  • 15. Riak Core helps you build a service that harnesses the power of many nodes. Node A Node B Node C Node D Node E Node F Node G Node H Service Node I Node J Node K Node L Node M Node N Node O ... Monday, November 22, 2010
  • 16. How does Riak Core work? 16 Monday, November 22, 2010
  • 17. A Simple Interface... Send commands, get responses. Command ObjectName, Payload How do we route the commands to physical machines? Monday, November 22, 2010
  • 18. Hash the Object Name Command ObjectName, Payload SHA1(ObjName), Payload 0 to 2^160 Monday, November 22, 2010
  • 19. A Naive Approach Command ObjectName, Payload SHA1(ObjName), Payload Node A Node B Node C Node D Monday, November 22, 2010
  • 20. A Naive Approach Command ObjectName, Payload SHA1(ObjName), Payload Existing routes become invalid when you add/remove nodes. Node A Node B Node C Node D Node E Monday, November 22, 2010
  • 21. "All problems in computer science can be solved by another level of indirection." - David Wheeler 21 Monday, November 22, 2010
  • 22. Routing with Consistent Hashing Command ObjectName, Payload SHA1(ObjName), Payload VNode 0 VNode 1 VNode 2 VNode 3 VNode 4 VNode 5 VNode 6 VNode 7 Node A Node B Node C Node D Monday, November 22, 2010
  • 23. Adding a Node Command ObjectName, Payload SHA1(ObjName), Payload VNode 0 VNode 1 VNode 2 VNode 3 VNode 4 VNode 5 VNode 6 VNode 7 Node A Node B Node C Node D Node E Monday, November 22, 2010
  • 24. Removing a Node Command ObjectName, Payload SHA1(ObjName), Payload VNode 0 VNode 1 VNode 2 VNode 3 VNode 4 VNode 5 VNode 6 VNode 7 Node A Node B Node C Node D Node E Monday, November 22, 2010
  • 25. The Ring Hash Location Monday, November 22, 2010
  • 26. Writing Replicas (N Value) Locations when N=3 Monday, November 22, 2010
  • 27. Routing Around Failures X Locations when N=3 and node 0 is down. Monday, November 22, 2010
  • 28. The Preflist Preflist Monday, November 22, 2010
  • 29. Location of the Routing Layer 29 Monday, November 22, 2010
  • 30. Router in the Middle Leads to SPOF Client Client Client Router VNode VNode VNode VNode VNode VNode VNode VNode 0 1 3 4 2 5 6 7 Node A Node B Node C Node D Node E Monday, November 22, 2010
  • 31. Riak Core - Router on Each Node Client Client Client Router Router Router Router Router VNode VNode VNode VNode VNode VNode VNode VNode 0 1 3 4 2 5 6 7 Node A Node B Node C Node D Node E Monday, November 22, 2010
  • 32. Eventually - Router in the Client Client Client Client Router Router Router VNode VNode VNode VNode VNode VNode VNode VNode 0 1 3 4 2 5 6 7 Node A Node B Node C Node D Node E Why isn’t this done yet? Time and complexity. Monday, November 22, 2010
  • 33. How Do The Routers Reach Agreement? Router Router Router Router Router VNode VNode VNode VNode VNode VNode VNode VNode 0 1 3 4 2 5 6 7 Node A Node B Node C Node D Node E Monday, November 22, 2010
  • 34. The Nodes Gossip Their World View Local Incoming Ring State Ring State Are rings equivalent? Strictly descendent? Or different? Monday, November 22, 2010
  • 35. Not Mentioned Vector Clocks Merkle Trees Bloom Filters 35 Monday, November 22, 2010
  • 36. Building an Application with Riak Core 36 Monday, November 22, 2010
  • 37. Building an Application on Riak Core? Two things to think about: The Command Set Command = ObjectName, Payload The commands/requests/operations that you will send through the system. The VNode Module The callback module that will receive the commands. 37 Monday, November 22, 2010
  • 38. Writing a VNode Module Startup/Shutdown init([Partition]) -> {ok, State} terminate(State) -> ok Receive Incoming Commands handle_command(Cmd, Sender, State) -> {noreply, State1} | {reply, Reply, State1} handle_handoff_command(Cmd, Sender, State) -> {noreply, State1} | {reply, ok, State1} 38 Monday, November 22, 2010
  • 39. Writing a VNode Module Send and Receive Handoff Data handoff_starting(Node, State) -> {Bool, State1} encode_handoff_data(Data, State) -> <<Binary>>. handle_handoff_data(Data, Sender, State) -> {reply, ok, State1} handoff_finished(Node, State) -> {ok, State1} 39 Monday, November 22, 2010
  • 40. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_node_* X_vnode X_vnode riak_core_ring_* riak_core_gossip_* X_vnode ... application:start(riak_core). 40 Monday, November 22, 2010
  • 41. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_node_* X_vnode X_vnode riak_core_ring_* riak_core_gossip_* X_vnode ... Supervise vnode processes. 41 Monday, November 22, 2010
  • 42. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_node_* X_vnode X_vnode riak_core_ring_* riak_core_gossip_* X_vnode ... Start, coordinate, and supervise handoff. 42 Monday, November 22, 2010
  • 43. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_node_* X_vnode X_vnode riak_core_ring_* riak_core_gossip_* X_vnode ... Maintain cluster membership information. 43 Monday, November 22, 2010
  • 44. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_node_* X_vnode X_vnode riak_core_ring_* riak_core_gossip_* X_vnode ... Monitor node liveness, broadcast to registered modules. 44 Monday, November 22, 2010
  • 45. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_node_* X_vnode X_vnode riak_core_ring_* riak_core_gossip_* X_vnode ... Send ring information to other nodes. Reconcile different views of the cluster. Rebalance cluster when nodes join or leave. 45 Monday, November 22, 2010
  • 46. In your application... riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_node_* X_vnode X_vnode riak_core_ring_* riak_core_gossip_* X_vnode ... Start the vnodes for your application. Master = { riak_X_vnode_master, { riak_core_vnode_master, start_link, [riak_X_vnode] }, permanent, 5000, worker, [riak_core_vnode_master] }, {ok, { {one_for_one, 5, 10}, [Master]} }. 46 Monday, November 22, 2010
  • 47. In your application... riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_node_* X_vnode X_vnode riak_core_ring_* riak_core_gossip_* X_vnode ... Tell riak_core that your application is ready to receive requests. riak_core:register_vnode_module(riak_X_vnode), riak_core_node_watcher:service_up(riak_X, self()) 47 Monday, November 22, 2010
  • 48. In your application... riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_node_* X_vnode X_vnode riak_core_ring_* riak_core_gossip_* X_vnode ... riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_node_* X_vnode X_vnode riak_core_ring_* riak_core_gossip_* X_vnode ... Join to an existing node in the cluster. riak_core_gossip:send_ring(ClusterNode, node()) 48 Monday, November 22, 2010
  • 49. Start Sending Commands # Figure out the preflist... {_Verb, ObjName, _Payload} = Command, PrefList = riak_core_apl:get_apl(ObjName, NVal, riak_X), # Send the command... riak_core_vnode_master:command(PrefList, Command, riak_X_vnode_master) 49 Monday, November 22, 2010
  • 50. Review Riak KV Open Source Key/Value datastore. Riak Search Full-text, near real-time search engine based on Riak Core. Riak Core Open Source Erlang library that helps you build distributed, scalable, failure-tolerant applications using a Dynamo-style architecture. 50 Monday, November 22, 2010
  • 51. Thanks! Questions? Learn More http://wiki.basho.com Read Amazon’s Dynamo Paper Get the Code http://github.com/basho/riak_core Get in Touch rusty@basho.com on Email @rklophaus on Twitter 51 Monday, November 22, 2010
  • 52. END Monday, November 22, 2010