Massively Scalable
.NET Web Services w/
Project Orleans
DECEMBER 5TH 2016 – NEWMAN SCOTT HUNTER
SCOTT@DRIFTLOGIC.NET
SCOTTHUNTER@EA.COM
Who is this guy?
Agenda
• Introducing Orleans
• Basic Actor Concepts
• OrleansTerminology
• Orleans in Action
• Use Cases and Gotchas
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
What are Actors?
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.
Thread One Thread Two Thread Three
Memory
Memory
Memory
Memory
Thread A Thread B
Orleans Terminology
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*
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
Orleans Terminology
• Each Orleans ‘Actor’ is a ‘Grain’. A grain SHOULD correspond
to a discrete unit.
Orleans Terminology
• Each ‘Grain’ receives one ‘Turn’ when executing awaiting
messages, and may send messages to other ‘Grain’s
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
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.
Orleans Terminology
• Each Silo has a client access port, so requests to any grain can
be addressed to any silo.
Orleans Terminology
IIS
Orleans in Action
Orleans in Action
• Three core components
• Interface
• Implementation
• Access
Orleans in Action
Orleans in Action
• Possible Grain Keys (As Defined by the Interface)
• Guid
• Long
• String
• ‘Compound Primary’
• Hash of a GUID and a Long
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.
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)
Orleans in Action
Orleans in Action
Use Cases and Gotchas
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.
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.
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.
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

Massively Scaleable .NET Web Services with Project Orleans

  • 1.
    Massively Scalable .NET WebServices w/ Project Orleans DECEMBER 5TH 2016 – NEWMAN SCOTT HUNTER SCOTT@DRIFTLOGIC.NET SCOTTHUNTER@EA.COM
  • 2.
  • 3.
    Agenda • Introducing Orleans •Basic Actor Concepts • OrleansTerminology • Orleans in Action • Use Cases and Gotchas
  • 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
  • 5.
  • 6.
    What are Actors? Aframework for concurrency based on Message Passing between objects that eliminates (or greatly reduces) the developer overhead involved in multithreaded development.
  • 7.
    Thread One ThreadTwo Thread Three Memory
  • 8.
  • 9.
  • 10.
  • 11.
  • 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 VIRTUALactors? • Must be instantiated before messages can be received. Concrete Actors • Can be messaged regardless if they have been created. Virtual Actors
  • 14.
    Orleans Terminology • EachOrleans ‘Actor’ is a ‘Grain’. A grain SHOULD correspond to a discrete unit.
  • 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 • Acluster 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 • EachSilo has a client access port, so requests to any grain can be addressed to any silo.
  • 19.
  • 20.
  • 21.
    Orleans in Action •Three core components • Interface • Implementation • Access
  • 22.
  • 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 UseCase • 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)
  • 26.
  • 27.
  • 28.
  • 29.
    Use Cases andGotchas [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 andGotchas 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 andGotchas 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/ Halo4Web 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