SlideShare ist ein Scribd-Unternehmen logo
1 von 52
Downloaden Sie, um offline zu lesen
Rusty Klophaus (@rklophaus)
BashoTechnologies
Masterless Distributed
Computing with Riak Core
Erlang User Conference
Stockholm, Sweden · November 2010
Monday, November 22, 2010
BashoTechnologies
2
About BashoTechnologies
• 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
Monday, November 22, 2010
Riak KV and Riak Search
3
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.
Monday, November 22, 2010
Riak
KV
Riak
Search
Riak
Core
The Common Parts are called Riak Core
Monday, November 22, 2010
Riak
KV
Riak
Search
Riak
Core
The Common Parts are called Riak Core
Distribution / Scaling /
Failure-Tolerance Code
Monday, November 22, 2010
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
“We Generalized the
Dynamo Architecture and
Open-Sourced the Bits.”
7
Monday, November 22, 2010
What Areas are Covered?
Amazon’s Dynamo Paper highlighted to
show parts covered in Riak Core.
Monday, November 22, 2010
Distributed, scalable, failure-tolerant.
9
Monday, November 22, 2010
Distributed, scalable, failure-tolerant.
No central coordinator.
Easy to setup/operate.
10
Monday, November 22, 2010
Distributed, scalable, failure-tolerant.
Horizontally scalable;
add commodity hardware
to get more X.
11
Monday, November 22, 2010
Distributed, scalable, failure-tolerant.
Always available.
No single point of failure.
Self-healing.
12
Monday, November 22, 2010
Wait, doesn’t *Erlang* let you build
distributed, scalable, failure-tolerant
applications?
13
Monday, November 22, 2010
Client
Service A Service B
Resource D
Service C
Queue E
Erlang makes it easy to connect the
components of your application.
Monday, November 22, 2010
Service
Node A
Node E
Node I
Node M
Node B
Node F
Node J
Node N
Node C
Node G
Node K
Node O
Node D
Node H
Node L
. . .
Riak Core helps you build a service that
harnesses the power of many nodes.
Monday, November 22, 2010
How does Riak Core work?
16
Monday, November 22, 2010
A Simple Interface...
Command ObjectName, Payload
Send commands, get responses.
How do we route the commands
to physical machines?
Monday, November 22, 2010
Hash the Object Name
Command ObjectName, Payload
SHA1(ObjName), Payload
0 to 2^160
Monday, November 22, 2010
A Naive Approach
Command ObjectName, Payload
SHA1(ObjName), Payload
Node A Node B Node C Node D
Monday, November 22, 2010
A Naive Approach
Command
SHA1(ObjName), Payload
Node A Node B Node C Node D Node E
ObjectName, Payload
Existing routes become invalid
when you add/remove nodes.
Monday, November 22, 2010
"All problems in computer
science can be solved by
another level of indirection."
- David Wheeler
21
Monday, November 22, 2010
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
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
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
The Ring
Hash Location
Monday, November 22, 2010
Writing Replicas (NValue)
Locations when N=3
Monday, November 22, 2010
Routing Around Failures
Locations when N=3
and node 0 is down.
X
Monday, November 22, 2010
The Preflist
Preflist
Monday, November 22, 2010
Location of the Routing Layer
29
Monday, November 22, 2010
Router in the Middle Leads to SPOF
Client Client Client
Router
VNode
0
Node A Node B Node C Node D Node E
VNode
1
VNode
3
VNode
4
VNode
2
VNode
5
VNode
6
VNode
7
Monday, November 22, 2010
Riak Core - Router on Each Node
Client Client Client
Router Router Router RouterRouter
VNode
0
Node A Node B Node C Node D Node E
VNode
1
VNode
3
VNode
4
VNode
2
VNode
5
VNode
6
VNode
7
Monday, November 22, 2010
Eventually - Router in the Client
Client Client Client
VNode
0
Node A Node B Node C Node D Node E
VNode
1
VNode
3
VNode
4
VNode
2
VNode
5
VNode
6
VNode
7
Router RouterRouter
Why isn’t this done yet?
Time and complexity.
Monday, November 22, 2010
How DoThe Routers Reach Agreement?
Router Router Router RouterRouter
VNode
0
Node A Node B Node C Node D Node E
VNode
1
VNode
3
VNode
4
VNode
2
VNode
5
VNode
6
VNode
7
Monday, November 22, 2010
The Nodes GossipTheir WorldView
Local
Ring State
Incoming
Ring State
Are rings equivalent?
Strictly descendent?
Or different?
Monday, November 22, 2010
Not Mentioned
Vector Clocks
MerkleTrees
Bloom Filters
35
Monday, November 22, 2010
Building an Application
with Riak Core
36
Monday, November 22, 2010
Building an Application on Riak Core?
Two things to think about:
37
The Command Set
Command = ObjectName, Payload
The commands/requests/operations that you will send
through the system.
TheVNode Module
The callback module that will receive the commands.
Monday, November 22, 2010
Writing aVNode Module
38
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}
Monday, November 22, 2010
Writing aVNode Module
39
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}
Monday, November 22, 2010
Start the riak_core application
riak_core
riak_core_vnode_sup riak_core_handoff_*
riak_core_ring_*
riak_core_node_*
riak_core_gossip_*
X_vnode
. . .
X_vnode
X_vnode
40
application:start(riak_core).
Monday, November 22, 2010
Start the riak_core application
riak_core
riak_core_vnode_sup riak_core_handoff_*
riak_core_ring_*
riak_core_node_*
riak_core_gossip_*
X_vnode
. . .
X_vnode
X_vnode
41
Supervise vnode processes.
Monday, November 22, 2010
Start the riak_core application
riak_core
riak_core_vnode_sup riak_core_handoff_*
riak_core_ring_*
riak_core_node_*
riak_core_gossip_*
X_vnode
. . .
X_vnode
X_vnode
42
Start, coordinate, and supervise handoff.
Monday, November 22, 2010
Start the riak_core application
riak_core
riak_core_vnode_sup riak_core_handoff_*
riak_core_ring_*
riak_core_node_*
riak_core_gossip_*
X_vnode
. . .
X_vnode
X_vnode
43
Maintain cluster membership information.
Monday, November 22, 2010
Start the riak_core application
riak_core
riak_core_vnode_sup riak_core_handoff_*
riak_core_ring_*
riak_core_node_*
riak_core_gossip_*
X_vnode
. . .
X_vnode
X_vnode
44
Monitor node liveness,
broadcast to registered modules.
Monday, November 22, 2010
Start the riak_core application
riak_core
riak_core_vnode_sup riak_core_handoff_*
riak_core_ring_*
riak_core_node_*
riak_core_gossip_*
X_vnode
. . .
X_vnode
X_vnode
45
Send ring information to other nodes.
Reconcile different views of the cluster.
Rebalance cluster when nodes join or leave.
Monday, November 22, 2010
In your application...
riak_core
riak_core_vnode_sup riak_core_handoff_*
riak_core_ring_*
riak_core_node_*
riak_core_gossip_*
X_vnode
. . .
X_vnode
X_vnode
46
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]} }.
Monday, November 22, 2010
In your application...
riak_core
riak_core_vnode_sup riak_core_handoff_*
riak_core_ring_*
riak_core_node_*
riak_core_gossip_*
X_vnode
. . .
X_vnode
X_vnode
47
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())
Monday, November 22, 2010
In your application...
riak_core
riak_core_vnode_sup riak_core_handoff_*
riak_core_ring_*
riak_core_node_*
riak_core_gossip_*
X_vnode
. . .
X_vnode
X_vnode
riak_core
riak_core_vnode_sup riak_core_handoff_*
riak_core_ring_*
riak_core_node_*
riak_core_gossip_*
X_vnode
. . .
X_vnode
X_vnode
48
Join to an existing node in the cluster.
riak_core_gossip:send_ring(ClusterNode,
node())
Monday, November 22, 2010
Start Sending Commands
49
# 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)
Monday, November 22, 2010
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
Thanks! Questions?
Learn More
http://wiki.basho.com
Read Amazon’s Dynamo Paper
Get the Code
http://github.com/basho/riak_core
Get inTouch
rusty@basho.com on Email
@rklophaus onTwitter
51
Monday, November 22, 2010
END
Monday, November 22, 2010

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18
 
Containerization & Docker - Under the Hood
Containerization & Docker - Under the HoodContainerization & Docker - Under the Hood
Containerization & Docker - Under the Hood
 
Union FileSystem - A Building Blocks Of a Container
Union FileSystem - A Building Blocks Of a ContainerUnion FileSystem - A Building Blocks Of a Container
Union FileSystem - A Building Blocks Of a Container
 
Kubernetes security
Kubernetes securityKubernetes security
Kubernetes security
 
One More State Management in Angular (NGRX vs. NGXS vs. Akita vs. RXJS)
One More State Management in Angular (NGRX vs. NGXS vs. Akita vs. RXJS)One More State Management in Angular (NGRX vs. NGXS vs. Akita vs. RXJS)
One More State Management in Angular (NGRX vs. NGXS vs. Akita vs. RXJS)
 
The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...
The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...
The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...
 
Intro to kubernetes
Intro to kubernetesIntro to kubernetes
Intro to kubernetes
 
Docker networking Tutorial 101
Docker networking Tutorial 101Docker networking Tutorial 101
Docker networking Tutorial 101
 
Learning how AWS implement AWS VPC CNI
Learning how AWS implement AWS VPC CNILearning how AWS implement AWS VPC CNI
Learning how AWS implement AWS VPC CNI
 
Neo4j Training Introduction
Neo4j Training IntroductionNeo4j Training Introduction
Neo4j Training Introduction
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
How Graph Data Science can turbocharge your Knowledge Graph
How Graph Data Science can turbocharge your Knowledge GraphHow Graph Data Science can turbocharge your Knowledge Graph
How Graph Data Science can turbocharge your Knowledge Graph
 
Service-mesh options with Linkerd, Consul, Istio and AWS AppMesh
Service-mesh options with Linkerd, Consul, Istio and AWS AppMeshService-mesh options with Linkerd, Consul, Istio and AWS AppMesh
Service-mesh options with Linkerd, Consul, Istio and AWS AppMesh
 
NoSQL databases
NoSQL databasesNoSQL databases
NoSQL databases
 
Introduction to PyTorch
Introduction to PyTorchIntroduction to PyTorch
Introduction to PyTorch
 
Neo4j session
Neo4j sessionNeo4j session
Neo4j session
 
Implementation of Thorup's Linear Time Algorithm for Undirected Single Source...
Implementation of Thorup's Linear Time Algorithm for Undirected Single Source...Implementation of Thorup's Linear Time Algorithm for Undirected Single Source...
Implementation of Thorup's Linear Time Algorithm for Undirected Single Source...
 
Service Mesh - Why? How? What?
Service Mesh - Why? How? What?Service Mesh - Why? How? What?
Service Mesh - Why? How? What?
 
Real time analytics at uber @ strata data 2019
Real time analytics at uber @ strata data 2019Real time analytics at uber @ strata data 2019
Real time analytics at uber @ strata data 2019
 
Recurrent Neural Networks
Recurrent Neural NetworksRecurrent Neural Networks
Recurrent Neural Networks
 

Ähnlich wie Masterless Distributed Computing with Riak Core - EUC 2010

Atom The Redis Streams-Powered Microservices SDK: Dan Pipemazo
Atom The Redis Streams-Powered Microservices SDK: Dan PipemazoAtom The Redis Streams-Powered Microservices SDK: Dan Pipemazo
Atom The Redis Streams-Powered Microservices SDK: Dan Pipemazo
Redis Labs
 

Ähnlich wie Masterless Distributed Computing with Riak Core - EUC 2010 (20)

Nanog75, Network Device Property as Code
Nanog75, Network Device Property as CodeNanog75, Network Device Property as Code
Nanog75, Network Device Property as Code
 
Atom The Redis Streams-Powered Microservices SDK: Dan Pipemazo
Atom The Redis Streams-Powered Microservices SDK: Dan PipemazoAtom The Redis Streams-Powered Microservices SDK: Dan Pipemazo
Atom The Redis Streams-Powered Microservices SDK: Dan Pipemazo
 
Let's build a robot with ROS - Internet of Things, Hardware & Robotics meetup...
Let's build a robot with ROS - Internet of Things, Hardware & Robotics meetup...Let's build a robot with ROS - Internet of Things, Hardware & Robotics meetup...
Let's build a robot with ROS - Internet of Things, Hardware & Robotics meetup...
 
SDNs: hot topics, evolution & research opportunities
SDNs: hot topics, evolution & research opportunitiesSDNs: hot topics, evolution & research opportunities
SDNs: hot topics, evolution & research opportunities
 
Networking in Openstack - Neutron 101
Networking in Openstack - Neutron 101Networking in Openstack - Neutron 101
Networking in Openstack - Neutron 101
 
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoTInria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
 
OpenStack cloud for ConoHa, Z.com and GMO AppsCloud in okinawa opendays 2015 ...
OpenStack cloud for ConoHa, Z.com and GMO AppsCloud in okinawa opendays 2015 ...OpenStack cloud for ConoHa, Z.com and GMO AppsCloud in okinawa opendays 2015 ...
OpenStack cloud for ConoHa, Z.com and GMO AppsCloud in okinawa opendays 2015 ...
 
Banog meetup August 30th, network device property as code
Banog meetup August 30th, network device property as codeBanog meetup August 30th, network device property as code
Banog meetup August 30th, network device property as code
 
Knot.x: when Vert.x and RxJava meet
Knot.x: when Vert.x and RxJava meetKnot.x: when Vert.x and RxJava meet
Knot.x: when Vert.x and RxJava meet
 
OpenDaylight Netvirt and Neutron - Mike Kolesnik, Josh Hershberg - OpenStack ...
OpenDaylight Netvirt and Neutron - Mike Kolesnik, Josh Hershberg - OpenStack ...OpenDaylight Netvirt and Neutron - Mike Kolesnik, Josh Hershberg - OpenStack ...
OpenDaylight Netvirt and Neutron - Mike Kolesnik, Josh Hershberg - OpenStack ...
 
Mirantis OpenStack-DC-Meetup 17 Sept 2014
Mirantis OpenStack-DC-Meetup 17 Sept 2014Mirantis OpenStack-DC-Meetup 17 Sept 2014
Mirantis OpenStack-DC-Meetup 17 Sept 2014
 
Where are yours vertexes and what are they talking about?
Where are yours vertexes and what are they talking about?Where are yours vertexes and what are they talking about?
Where are yours vertexes and what are they talking about?
 
Openflow勉強会 「OpenFlowコントローラを取り巻く状況とその実装」
Openflow勉強会 「OpenFlowコントローラを取り巻く状況とその実装」Openflow勉強会 「OpenFlowコントローラを取り巻く状況とその実装」
Openflow勉強会 「OpenFlowコントローラを取り巻く状況とその実装」
 
Considerations for using NoSQL technology on your next IT project - Akmal Cha...
Considerations for using NoSQL technology on your next IT project - Akmal Cha...Considerations for using NoSQL technology on your next IT project - Akmal Cha...
Considerations for using NoSQL technology on your next IT project - Akmal Cha...
 
Why we need internet of things on Node.js
Why we need internet of things on Node.jsWhy we need internet of things on Node.js
Why we need internet of things on Node.js
 
NoSQL Introduction
NoSQL IntroductionNoSQL Introduction
NoSQL Introduction
 
NoSQL Introduction
NoSQL IntroductionNoSQL Introduction
NoSQL Introduction
 
Know Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express EditionKnow Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express Edition
 
Red Hat OpenStack - Open Cloud Infrastructure
Red Hat OpenStack - Open Cloud InfrastructureRed Hat OpenStack - Open Cloud Infrastructure
Red Hat OpenStack - Open Cloud Infrastructure
 
Webinar about Spring Data Neo4j 4
Webinar about Spring Data Neo4j 4Webinar about Spring Data Neo4j 4
Webinar about Spring Data Neo4j 4
 

Mehr von Rusty Klophaus

Mehr von Rusty Klophaus (10)

Everybody Polyglot! - Cross-Language RPC with Erlang
Everybody Polyglot! - Cross-Language RPC with ErlangEverybody Polyglot! - Cross-Language RPC with Erlang
Everybody Polyglot! - Cross-Language RPC with Erlang
 
Winning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleWinning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test Cycle
 
Querying Riak Just Got Easier - Introducing Secondary Indices
Querying Riak Just Got Easier - Introducing Secondary IndicesQuerying Riak Just Got Easier - Introducing Secondary Indices
Querying Riak Just Got Easier - Introducing Secondary Indices
 
Riak - From Small to Large - StrangeLoop
Riak - From Small to Large - StrangeLoopRiak - From Small to Large - StrangeLoop
Riak - From Small to Large - StrangeLoop
 
Riak - From Small to Large
Riak - From Small to LargeRiak - From Small to Large
Riak - From Small to Large
 
Riak Core: Building Distributed Applications Without Shared State
Riak Core: Building Distributed Applications Without Shared StateRiak Core: Building Distributed Applications Without Shared State
Riak Core: Building Distributed Applications Without Shared State
 
Riak Search - Erlang Factory London 2010
Riak Search - Erlang Factory London 2010Riak Search - Erlang Factory London 2010
Riak Search - Erlang Factory London 2010
 
Riak Search - Berlin Buzzwords 2010
Riak Search - Berlin Buzzwords 2010Riak Search - Berlin Buzzwords 2010
Riak Search - Berlin Buzzwords 2010
 
Riak from Small to Large
Riak from Small to LargeRiak from Small to Large
Riak from Small to Large
 
Getting Started with Riak - NoSQL Live 2010 - Boston
Getting Started with Riak - NoSQL Live 2010 - BostonGetting Started with Riak - NoSQL Live 2010 - Boston
Getting Started with Riak - NoSQL Live 2010 - Boston
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Masterless Distributed Computing with Riak Core - EUC 2010

  • 1. Rusty Klophaus (@rklophaus) BashoTechnologies Masterless Distributed Computing with Riak Core Erlang User Conference Stockholm, Sweden · November 2010 Monday, November 22, 2010
  • 2. BashoTechnologies 2 About BashoTechnologies • 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 Monday, November 22, 2010
  • 3. Riak KV and Riak Search 3 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. Monday, November 22, 2010
  • 4. Riak KV Riak Search Riak Core The Common Parts are called Riak Core Monday, November 22, 2010
  • 5. Riak KV Riak Search Riak Core The Common Parts are called Riak Core 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
  • 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. Client Service A Service B Resource D Service C Queue E Erlang makes it easy to connect the components of your application. Monday, November 22, 2010
  • 15. Service Node A Node E Node I Node M Node B Node F Node J Node N Node C Node G Node K Node O Node D Node H Node L . . . Riak Core helps you build a service that harnesses the power of many nodes. Monday, November 22, 2010
  • 16. How does Riak Core work? 16 Monday, November 22, 2010
  • 17. A Simple Interface... Command ObjectName, Payload Send commands, get responses. 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 SHA1(ObjName), Payload Node A Node B Node C Node D Node E ObjectName, Payload Existing routes become invalid when you add/remove nodes. 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 (NValue) Locations when N=3 Monday, November 22, 2010
  • 27. Routing Around Failures Locations when N=3 and node 0 is down. X 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 0 Node A Node B Node C Node D Node E VNode 1 VNode 3 VNode 4 VNode 2 VNode 5 VNode 6 VNode 7 Monday, November 22, 2010
  • 31. Riak Core - Router on Each Node Client Client Client Router Router Router RouterRouter VNode 0 Node A Node B Node C Node D Node E VNode 1 VNode 3 VNode 4 VNode 2 VNode 5 VNode 6 VNode 7 Monday, November 22, 2010
  • 32. Eventually - Router in the Client Client Client Client VNode 0 Node A Node B Node C Node D Node E VNode 1 VNode 3 VNode 4 VNode 2 VNode 5 VNode 6 VNode 7 Router RouterRouter Why isn’t this done yet? Time and complexity. Monday, November 22, 2010
  • 33. How DoThe Routers Reach Agreement? Router Router Router RouterRouter VNode 0 Node A Node B Node C Node D Node E VNode 1 VNode 3 VNode 4 VNode 2 VNode 5 VNode 6 VNode 7 Monday, November 22, 2010
  • 34. The Nodes GossipTheir WorldView Local Ring State Incoming Ring State Are rings equivalent? Strictly descendent? Or different? Monday, November 22, 2010
  • 35. Not Mentioned Vector Clocks MerkleTrees 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: 37 The Command Set Command = ObjectName, Payload The commands/requests/operations that you will send through the system. TheVNode Module The callback module that will receive the commands. Monday, November 22, 2010
  • 38. Writing aVNode Module 38 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} Monday, November 22, 2010
  • 39. Writing aVNode Module 39 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} Monday, November 22, 2010
  • 40. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_ring_* riak_core_node_* riak_core_gossip_* X_vnode . . . X_vnode X_vnode 40 application:start(riak_core). Monday, November 22, 2010
  • 41. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_ring_* riak_core_node_* riak_core_gossip_* X_vnode . . . X_vnode X_vnode 41 Supervise vnode processes. Monday, November 22, 2010
  • 42. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_ring_* riak_core_node_* riak_core_gossip_* X_vnode . . . X_vnode X_vnode 42 Start, coordinate, and supervise handoff. Monday, November 22, 2010
  • 43. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_ring_* riak_core_node_* riak_core_gossip_* X_vnode . . . X_vnode X_vnode 43 Maintain cluster membership information. Monday, November 22, 2010
  • 44. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_ring_* riak_core_node_* riak_core_gossip_* X_vnode . . . X_vnode X_vnode 44 Monitor node liveness, broadcast to registered modules. Monday, November 22, 2010
  • 45. Start the riak_core application riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_ring_* riak_core_node_* riak_core_gossip_* X_vnode . . . X_vnode X_vnode 45 Send ring information to other nodes. Reconcile different views of the cluster. Rebalance cluster when nodes join or leave. Monday, November 22, 2010
  • 46. In your application... riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_ring_* riak_core_node_* riak_core_gossip_* X_vnode . . . X_vnode X_vnode 46 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]} }. Monday, November 22, 2010
  • 47. In your application... riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_ring_* riak_core_node_* riak_core_gossip_* X_vnode . . . X_vnode X_vnode 47 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()) Monday, November 22, 2010
  • 48. In your application... riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_ring_* riak_core_node_* riak_core_gossip_* X_vnode . . . X_vnode X_vnode riak_core riak_core_vnode_sup riak_core_handoff_* riak_core_ring_* riak_core_node_* riak_core_gossip_* X_vnode . . . X_vnode X_vnode 48 Join to an existing node in the cluster. riak_core_gossip:send_ring(ClusterNode, node()) Monday, November 22, 2010
  • 49. Start Sending Commands 49 # 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) 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 inTouch rusty@basho.com on Email @rklophaus onTwitter 51 Monday, November 22, 2010