more than data
DESCRIPTION
Slides for a talk given at RICON West 2013. Video is available at the very beginning of Day 1, Track 2 here: http://ricon.io/west2013.html Full edited videos will be available at a later date. This talk is about how StackMob uses Riak Core for distributing services.TRANSCRIPT
MORE THAN DATAUsing Riak Core to Manage Distributed
Services
Who Am I?
Miles O’Connell
@milesoc (twitter/github)
Software Engineer at StackMob
Backend-As-A-Service
• Data API
• Push
• Third Party Marketplace
• etc.
Backend-As-A-Service
• Data API
• Push
• Third Party Marketplace
• etc.
Service Oriented Architecture (SOA)
Service Oriented Architecture
Creative Commons License – Flickr/Jared Tarbell
CAP Theorem
• Consistency
• Availability
• Partition Tolerance
Service Oriented Architecture
• Versioning (“Consistency”)
• Availability
• Partition Tolerance
Service Oriented Architecture
Service A Service B
Service C Service D
Service Oriented Architecture
Service A Service B
Service C Service D
Service B
(v2)
Service D
(v2)
Service Oriented Architecture
Service A Service B
Service C Service D
Service B
(v2)
Service D
(v2)
Service Oriented Architecture
Service A
Service C
Service B
(v2)
Service D
(v2)
Service Oriented Architecture
• Versioning (“Consistency”)
• Availability
• Partition Tolerance
Custom Code
Data API Push API Versioning
3rd Partyetc.
etc.etc.
Custom Code
Data API Push API Versioning
3rd Partyetc.
etc.etc.
Custom Code
Custom Code
Data API Push API Versioning
3rd Partyetc.
etc.etc.
Service Oriented Architecture
• Versioning (“Consistency”)
• Availability
• Partition Tolerance
Service Oriented Architecture
• Versioning (“Consistency”)
• Availability
• Partition Tolerance
• Automated
Riak Core
• https://github.com/basho/riak_core
• Erlang library for building distributed systems
Riak Core2160 0
Riak Core2160 0
Key
Riak Core
vnode
Riak Core
Physical Server 1
Physical Server 2
Physical Server 3
Riak Core
Physical Server 1
Physical Server 2
Physical Server 3
Riak Core
K, V
Physical Server 1
Physical Server 2
Physical Server 3
Riak Core
K, V
Physical Server 1
Physical Server 2
Physical Server 3
Riak Core
K, V
Physical Server 1
Physical Server 2
Physical Server 3
Riak Core
K, V
Physical Server 1
Physical Server 2
Physical Server 3
Riak Core
K, V
Physical Server 1
Physical Server 2Physical Server 3
Riak Core
K, V
Physical Server 1
Physical Server 2
Physical Server 3
Riak Core
K, V
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core
RequestService
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core
RequestCC
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core
RequestCC
Instance
Physical Server 1
Physical Server 2
SOA on Riak Core
Request
CC
Instance
Physical Server 1
Physical Server 2
SOA on Riak Core
Request
Webmachine
Physical Server 1
Physical Server 2
CC
Instance
SOA on Riak Core
Request
Webmachine
proxy_coord
Physical Server 1
Physical Server 2
CC
Instance
SOA on Riak Core
Request
Webmachine
proxy_coord
vnode
Physical Server 1
Physical Server 2
CC
Instance
SOA on Riak Core
Request
Webmachine
proxy_coord
vnode
instance_mgr
Physical Server 1
Physical Server 2
CC
Instance
SOA on Riak Core
Request
Webmachine
proxy_coord
vnode
Physical Server 1
Physical Server 2
proxy_op
instance_mgr
CC
Instance
SOA on Riak Core
Request
Webmachine
proxy_coord
vnode
Physical Server 1
Physical Server 2
proxy_op
instance_mgr
CC
Instance
SOA on Riak Core
Request
Webmachine
proxy_coord
vnode
Physical Server 1
Physical Server 2
proxy_op
instance_mgr
Deploy
deploy_coord
deploy_op
instance_mgr
CC
Instance
CC
Instance
SOA on Riak Core
RequestCC
Instance
Physical Server 1
Physical Server 2
Physical Server 3
Service Oriented Architecture
• Versioning (“Consistency”)
• Availability
• Partition Tolerance
• Automated
SOA on Riak Core - Replication
RequestService
Instance
Service
Instance
Service
Instance
SOA on Riak Core - Replication
• R
• How many replicas must we read
• W
• How many replicas must we write
• N
• How many replicas should exist
Riak Core - Replication
K, V
Riak Core - Replication
K, V
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Replication
Request
Physical Server 1
Physical Server 2
Physical Server 3
Service
Instance
Service
Instance
Service
Instance
SOA on Riak Core - Replication
RequestService
Instance
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
Service
Instance
SOA on Riak Core - Replication
RequestService
Instance
Service
Instance
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Replication
Request
Service
Instance
Service
Instance
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Replication
Request
Service
Instance
Service
Instance
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Replication
Request
Service
Instance
Service
Instance
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Replication
Request
Service
Instance
Service
Instance
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Replication
Deploy
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Replication
Deploy
Service
Instance
Service
Instance
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core
• Versioning (“Consistency”)
• Availability✔
• Partition Tolerance
SOA on Riak Core
• Versioning (“Consistency”)
• Availability✔
• Partition Tolerance
SOA on Riak Core - Handoff
Service
Instance
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Handoff
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Handoff
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Handoff
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Handoff
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Handoff
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Handoff
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core - Handoff
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
Service
Instance
SOA on Riak Core - Handoff
Service
Instance
Service
Instance
Physical Server 1
Physical Server 2
Physical Server 3
SOA on Riak Core
• Versioning (“Consistency”)
• Availability✔
• Partition Tolerance✔
SOA on Riak Core
• Versioning (“Consistency”)
• Availability✔
• Partition Tolerance✔
SOA on Riak Core - Versioning
Deploy
(v2)
Service
(v1)
Service
(v1)
Service
(v1)
SOA on Riak Core - Versioning
Deploy
(v2)
Service
(v1)
Service
(v1)
Service
(v1)
SOA on Riak Core - Versioning
/{service}/{version}/api/{endpoint}
SOA on Riak Core - Versioning
Request
Service
(v1)
Service
(v1)
Service
(v1)
Bastion
SOA on Riak Core - Versioning
Service B
(v1)
Service B
(v1)
Service A
(v1)
Service A
(v1)
SOA on Riak Core - Versioning
Service B
(v1)
Service B
(v1)
Service A
(v1)
Service A
(v1)
SOA on Riak Core - Versioning
Service B
(v1)
Service B
(v1)
Service A
(v1)
Service A
(v1)
Service A
(V2)
Service A
(V2)
Service B
(V2)
Service B
(V2)
SOA on Riak Core - Versioning
Service B
(v1)
Service B
(v1)
Service A
(v1)
Service A
(v1)
Service A
(V2)
Service A
(V2)
Service B
(V2)
Service B
(V2)
SOA on Riak Core - Versioning
Service B
(v1)
Service B
(v1)
Service A
(v1)
Service A
(v1)
Service A
(V2)
Service A
(V2)
Service B
(V2)
Service B
(V2)
SOA on Riak Core
• Versioning (“Consistency”) ✔?
• Availability✔
• Partition Tolerance✔
SOA on Riak Core - Integration
Three key features
SOA on Riak Core - Integration
Three key features
• Management API (Startup/Shutdown)
SOA on Riak Core - Integration
Three key features
• Management API (Startup/Shutdown)
• Consistent Service Responses
SOA on Riak Core - Integration
Three key features
• Management API (Startup/Shutdown)
• Consistent Service Responses
• Status Check Endpoint
SOA on Riak Core
• Riak Core can work for any distributed system
SOA on Riak Core
• Riak Core can work for any distributed system
• Riak Core provides:
• Availability
• Partition Tolerance
SOA on Riak Core
• Riak Core can work for any distributed system
• Riak Core provides:
• Availability
• Partition Tolerance
• You need external coordination (Consistency)
SOA on Riak Core
• Riak Core can work for any distributed system
• Riak Core provides:
• Availability
• Partition Tolerance
• You need external coordination (Consistency)
• You provide:
• Management API
• Consistent Responses
• Health Check
Acknowledgements
• Jordan West (GitHub: jrwest)
• Everyone at StackMob