Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Massively Scaleable .NET Web Services with Project Orleans


Published on

Presented at ConFoo Vancouver 2016 - December 5th 2016

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Massively Scaleable .NET Web Services with Project Orleans

  1. 1. Massively Scalable .NET Web Services w/ Project Orleans DECEMBER 5TH 2016 – NEWMAN SCOTT HUNTER SCOTT@DRIFTLOGIC.NET SCOTTHUNTER@EA.COM
  2. 2. Who is this guy?
  3. 3. Agenda • Introducing Orleans • Basic Actor Concepts • OrleansTerminology • Orleans in Action • Use Cases and Gotchas
  4. 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. 5. What are Actors?
  6. 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.
  7. 7. Thread One Thread Two Thread Three Memory
  8. 8. Memory
  9. 9. Memory
  10. 10. Memory Thread A Thread B
  11. 11. Orleans Terminology
  12. 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. 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
  14. 14. Orleans Terminology • Each Orleans ‘Actor’ is a ‘Grain’. A grain SHOULD correspond to a discrete unit.
  15. 15. Orleans Terminology • Each ‘Grain’ receives one ‘Turn’ when executing awaiting messages, and may send messages to other ‘Grain’s
  16. 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. 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. 18. Orleans Terminology • Each Silo has a client access port, so requests to any grain can be addressed to any silo.
  19. 19. Orleans Terminology IIS
  20. 20. Orleans in Action
  21. 21. Orleans in Action • Three core components • Interface • Implementation • Access
  22. 22. Orleans in Action
  23. 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. 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. 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)
  26. 26. Orleans in Action
  27. 27. Orleans in Action
  28. 28. Use Cases and Gotchas
  29. 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. 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. 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. 32. More Info Orleans Homepage Halo 4Web Services in Orleans Orleans MSR Home Page Azure ReliableActors Java Orbit Newman Scott Hunter