"walk in a distributed systems park with orleans" Евгений Бобров
TRANSCRIPT
![Page 1: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/1.jpg)
Walk in a distributed systems park with Orleans
Yevhen Bobrovyevhen
YouScan.io@
![Page 2: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/2.jpg)
Orleans is …
… runtime and programming model for building distributed systems based on actor model
![Page 3: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/3.jpg)
Built by eXtreme Computing Group at Microsoft Research
Has been used internally (during last few years)
Open-sourced in 2015(available on GitHub and Nuget)
![Page 4: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/4.jpg)
ScalabilityAvailabilityReliablity
built for *
![Page 5: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/5.jpg)
HALO4
Orleanspowered by
11+ million players1.5 billion games270 million hours
![Page 6: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/6.jpg)
Why do we need it?
![Page 7: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/7.jpg)
Stateless Services
Service
![Page 8: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/8.jpg)
Stateless Services
Service
![Page 9: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/9.jpg)
Stateless Services
ServiceService
![Page 10: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/10.jpg)
Stateless Services
ServiceService
![Page 11: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/11.jpg)
Stateless Services
ServiceService
![Page 12: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/12.jpg)
Stateless Services
ServiceService Service
![Page 13: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/13.jpg)
Stateless Services
ServiceService Service
![Page 14: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/14.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 15: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/15.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 16: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/16.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 17: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/17.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 18: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/18.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 19: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/19.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 20: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/20.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 21: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/21.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 22: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/22.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 23: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/23.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 24: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/24.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 25: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/25.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 26: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/26.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 27: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/27.jpg)
Service
Service
Service
Data Shipping Paradigm
![Page 28: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/28.jpg)
Stateless Services (a.k.a 3-tier)scales very badly
![Page 29: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/29.jpg)
In a Cloudlatency will kill you
![Page 30: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/30.jpg)
Stateful Services
![Page 31: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/31.jpg)
Service
Service
Service
Function Shipping Paradigm
![Page 32: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/32.jpg)
Service
Service
Service
Function Shipping Paradigm
![Page 33: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/33.jpg)
Service
Service
Service
Function Shipping Paradigm
![Page 34: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/34.jpg)
Service
Service
Service
Function Shipping Paradigm
![Page 35: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/35.jpg)
Service
Service
Service
Function Shipping Paradigm
![Page 36: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/36.jpg)
Service
Service
Service
Function Shipping Paradigm
![Page 37: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/37.jpg)
Service
Service
Service
Function Shipping Paradigm
![Page 38: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/38.jpg)
Service
Service
Service
Function Shipping Paradigm
![Page 39: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/39.jpg)
Service
Service
Service
Function Shipping Paradigm
![Page 40: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/40.jpg)
Service
Service
Service
Function Shipping Paradigm
![Page 41: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/41.jpg)
Service
Service
Service
Function Shipping Paradigm
![Page 42: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/42.jpg)
Stateful Services
![Page 43: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/43.jpg)
Stateful Services
shared state
![Page 44: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/44.jpg)
Stateful Services
shared stateconcurrency, locks, and all that jazz
![Page 45: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/45.jpg)
Stateful Services
shared stateconcurrency, locks, and all that jazz
PAIN
![Page 46: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/46.jpg)
Actor Model
Single-threaded execution (no need to use locks)
Data locality and consistency (due to encapsulation)
Objects on steroids
![Page 47: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/47.jpg)
Stateful Services
Actors make it simple
![Page 48: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/48.jpg)
How to distribute?
![Page 49: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/49.jpg)
Akka / Erlang
10.0.0.1
10.0.0.2
var game = activate(“game”, “tcp://10.0.0.1”)game.invoke(“foo()”)
var user = activate(“user”, “tcp://10.0.0.2”)user.invoke(“bar()”)
![Page 50: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/50.jpg)
Routing Problems
10.0.0.1
10.0.0.2
10.0.0.5
10.0.0.8
![Page 51: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/51.jpg)
Routing Problems
10.0.0.1
10.0.0.2
10.0.0.5
10.0.0.8
![Page 52: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/52.jpg)
Routing Problems
Cluster Membership
![Page 53: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/53.jpg)
Routing Problems
Cluster Membership Workload Distribution
![Page 54: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/54.jpg)
Routing Problems
Cluster Membership Workload Distribution
Static
![Page 55: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/55.jpg)
Routing Problems
Cluster Membership Workload Distribution
StaticDynamic
![Page 56: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/56.jpg)
Routing Problems
Cluster Membership Workload Distribution
StaticDynamic Distributed Consensus
![Page 57: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/57.jpg)
Routing Problems
Cluster Membership Workload Distribution
StaticDynamic Distributed Consensus
Timeouts
![Page 58: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/58.jpg)
Routing Problems
Cluster Membership Workload Distribution
StaticDynamic Distributed Consensus
TimeoutsLifecycle
![Page 59: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/59.jpg)
Routing Problems
Cluster Membership Workload Distribution
StaticDynamic Distributed Consensus
TimeoutsLifecycle
PAIN
![Page 60: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/60.jpg)
Orleans is …
… runtime and programming model for building distributed systems based on actor model
![Page 61: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/61.jpg)
ScalabilityAvailabilityReliablity
How?
![Page 62: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/62.jpg)
Virtual Actors
![Page 63: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/63.jpg)
Location Transparency
var game = activate(“game”, “tcp://10.0.0.1”)game.invoke(“foo()”)
Akka / Erlang
Orleansvar game = activate(“game”) “tcp://10.0.0.1”)game.invoke(“foo()”)
![Page 64: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/64.jpg)
Perpetual Existence
var game = activate(“game”, “tcp://10.0.0.1”)game.invoke(“foo()”)
Akka / Erlang
Orleansvar game = activate(“game”, “tcp://10.0.0.1”)game.invoke(“foo()”)
![Page 65: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/65.jpg)
inversion of control
• Placement• Lifecycle
Runtime takes care of
![Page 66: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/66.jpg)
New node joined the
cluster
Unavailable (crashed)
node
New Activation New actor activations
courtesy of @johnazariah
![Page 67: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/67.jpg)
Cooperative multitasking
![Page 68: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/68.jpg)
Threads ~= Cores
Core 1
Core 2
Core N
Mechanical sympathy
Scheduler(turns)
Thread 1
Thread N
![Page 69: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/69.jpg)
Non-blocking IOPromises (TPL, Task, Combinators)
Multiplexed TCPMillions of actors with low OS overhead
Automatic backpressure by designSynchronous, request-response messaging
![Page 70: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/70.jpg)
Tour De Orleans
![Page 71: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/71.jpg)
Grain(a.k.a. Actor)
Silo(a.k.a. Node)
Cluster(a.k.a. Cluster)
Major Concepts
![Page 72: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/72.jpg)
Define interface:
public interface IInventoryItemGrain : IGrain { Task Increment(int qty); Task Decrement(int qty); Task<int> Total(); }
![Page 73: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/73.jpg)
Define implementation:class InventoryItemGrain : Grain, IInventoryItemGrain{ int total;
public Task Increment(int qty) { total++; return TaskDone.Done; }
public Task Decrement(int qty) { total--; return TaskDone.Done; }
public Task<int> Total() => Task.FromResult(total);}
![Page 74: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/74.jpg)
Invoke:
var item = GrainFactory .GetGrain<IInventoryItemGrain>("iPhone");
await item.Increment(100);await item.Decrement(100);
Console.WriteLine(await item.Total());
![Page 75: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/75.jpg)
More Orleans
![Page 76: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/76.jpg)
Placement hints
• Random (default)
• Prefer-local (clustering actors)
• Distribute evenly (# of activations)
![Page 77: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/77.jpg)
Automatic deactivation(garbage collection)
• Global timeout (idle time)
• Per-actor type
• Imperative deactivation
![Page 78: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/78.jpg)
Timers/Reminders
• Async timers (single-threaded guarantee)
• Durable recurrent reminders
retries, recurrent tasks
![Page 79: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/79.jpg)
Streams
• Direct TCP / Azure Queues
• Durable Pub-Sub (WATS/SQL)
• Declarative subscriptions
• Cluster-wide
![Page 80: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/80.jpg)
When to use?
![Page 81: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/81.jpg)
Scaling 3-tier architecture(stateless services)
![Page 82: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/82.jpg)
IoT1. GPS Tracker (RFID, inventory, cars)2. Counters (running total)3. Sensor data
![Page 83: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/83.jpg)
Data stream processing1. Fraud detection2. Aggregation
![Page 84: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/84.jpg)
Ultra-scalable & reliable web crawling
![Page 85: "Walk in a distributed systems park with Orleans" Евгений Бобров](https://reader031.vdocument.in/reader031/viewer/2022030309/58f168511a28abc0338b45a3/html5/thumbnails/85.jpg)
END