This document introduces Orleans, a .NET framework for building scalable and distributed applications. Orleans uses an "actor model" where application logic is encapsulated in virtual actors that process messages asynchronously. The document defines Orleans terminology like grains, silos, and clusters. It also provides examples of how to structure grains and discusses use cases like stateless workers. Potential scaling issues are noted, such as the need to shard data storage and restart the cluster to redistribute grains at high load.
4. What is Orleans?
• .NET Framework used to create
Scalable, Distributed, .NET Applications
• Focused on low response latency and
high concurrency
• Usable in any .NET application (but
frequently used with WebAPI
Applications)
• Based on a system of VirtualActors
6. What are Actors?
A framework for concurrency based on Message
Passing between objects that eliminates (or
greatly reduces) the developer overhead involved
in multithreaded development.
12. What are actors?
• Actors have ‘message boxes’ where actions to be performed by the actor are
stored, and processed in the order they arrive.
• Actor message execution is typically single threaded*
• BecauseActors only execute messages stored in their inbox and can only
send messages to other Actors via their inboxes, issues with concurrency are
minimized*
13. What are VIRTUAL actors?
• Must be instantiated before
messages can be received.
Concrete Actors
• Can be messaged regardless
if they have been created.
Virtual Actors
15. Orleans Terminology
• Each ‘Grain’ receives one ‘Turn’ when executing awaiting
messages, and may send messages to other ‘Grain’s
16. Orleans Terminology
• Each ‘Grain’ must be created in a ‘Silo’.A silo is a process
containing the activated ‘Grains’, managers for activation and
persistence, messaging, grain directory, and scheduler.
Messaging / Serialization
Persistence /
Activation Manager
Actor Directory
Scheduler
17. Orleans Terminology
• A cluster consists of multiple silos. Each silo maintains a
directory of Grains activated within it and will pass messages to
grains created in other silos, if active.
18. Orleans Terminology
• Each Silo has a client access port, so requests to any grain can
be addressed to any silo.
23. Orleans in Action
• Possible Grain Keys (As Defined by the Interface)
• Guid
• Long
• String
• ‘Compound Primary’
• Hash of a GUID and a Long
24. Orleans in Action
• Grain Keys control the activation of each grain (Remember that each
grain has STATE and is backed by a datastore)
• Grain Activation (and destruction) has an overhead, but can also be
choke points.
• Keys for grains should be designed around the use case.
25. Orleans in Action
Use Case
• Working with User Information
• Performing Requests on
Multiple Users (in the same
request)
• Working with Group Session
Example Grain Key
• User ID (LONG or STRING)
• CONST LONG
• GUID (tracked within the
requesting client OR a grain)
29. Use Cases and Gotchas
[StatelessWorker]
• By default, Orleans activates only ONE copy of a grain across all silos.
• If a Grain is marked as StatelessWorker, then multiple copies of the
same grain will be created, per silo, as needed.
• If existing workers are busy, additional instances are created within the
silos automatically.
30. Use Cases and Gotchas
Scaling Orleans
• New Silos can be added at any time.
• Created grains do not redistribute, once a grain is created, it is tied to
the created silo
• To redistribute at high load, the cluster needs to be restarted, so that
grains are reactivated.
31. Use Cases and Gotchas
Orleans + Sharding
• For maximum impact, data storage needs to be SHARDED.
• If all grains perform data access on the same table (or document), then
Orleans makes it easier to overwhelm any particular table.
• Grains make it easier to fully utilize sharded data stores for maximum
throughput.
32. More Info
Orleans Homepage
https://dotnet.github.io/orleans/
Halo 4Web Services in Orleans
https://www.youtube.com/watch?v=rEa2nQrpEhc
Orleans MSR Home Page
https://www.microsoft.com/en-us/research/project/orleans-virtual-actors/
Azure ReliableActors
https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-actors-get-started
Java Orbit
https://github.com/orbit/orbit
Newman Scott Hunter
scott@driftlogic.net
scotthunter@ea.com