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.

A Brief Intro to Microsoft Orleans


Published on

A short and sweet introduction to Microsoft Orleans - - OSS actor programming framework from Microsoft Research. As presented in Alt.Net Israel ( meeting group, Dec 2016.

Published in: Software
  • Be the first to comment

A Brief Intro to Microsoft Orleans

  2. 2. MICROSOFT ORLEANS A framework for building distributed applications • Made by Microsoft Research • Free and Open Source (MIT License) • Production Ready (Halo 4, Azure Service Fabric)
  3. 3. TWO GOALS • Simple Distributed Programming • Scalable by Default • The Actor Model of Programming
  4. 4. ACTOR PROGRAMMING MODEL • An Actor is “Unit of Computation” that upon receiving a Message: • Can send Messages to other Actors. • Can Create new Actors. • Designates the behavior to be used for the next Message it receives. State + Logic
  5. 5. ACTORS • Encapsulate State and Logic • Run Concurrently • Communicate Asynchronously Via Message Passing • Addressable (Addresses can go in Messages)
  6. 6. SOMEWHAT CONTRIVED EXAMPLE Uri WhatsApp Group Shay Boris“Wanna hear a secret?”
  7. 7. ORLEANS: GRAIN = VIRTUAL ACTOR • Grains are C# Classes • Derived from GrainBase • Implement an Interface (ex: IUser or IConversation) • Messages Passing = Calling Interface Methods • Ex: SendMessageToMembers(string text) • Can be Stateless or Stateful
  8. 8. GRAIN EXAMPLE public class ConversationGrain : Grain, IConversation { // State private string AdminId; private IEnumberable<IUserGrain> Members; // Receive messages public async Task SendMessageToAdmin(string message) { // Send a message var admin = GrainFactory.GetGrain<IUserGrain>(AdminId); await admin.GetMessage(message); } //... }
  9. 9. GRAIN LIFECYCLE • Managed by Silos and Clusters • Grains always exist • Can be Active / Inactive • Garbage Collected • Single instance if Statefull • Many instances if Stateless Orleans Cluster Silo Silo Silo
  10. 10. GRAIN COMMUNICATION • Messages = Method Calls • Method Calls are Queued • Grains are Single Threaded • Addresses are C# References • Location is Transparent var grain = GrainFactory .GetGrain<IUserGrain>("Uri"); await grain.SayHello("World");
  11. 11. GRAIN PERSISTENCE Choose: • No State (Think functional!) • Transient State: In Memory • Persistent State: • Azure Table Storage • Shared ATS • Roll your own • Configurable per Grain • Implicitly Read upon Activation • Explicitly Written by Grain Logic • Storage Provider in charge of Serialization
  12. 12. DEPLOYMENT • Silos are self hosting • So Clusters run anywhere Windows can Ex: Azure Cloud Services (Worker Roles) • Server to Server over TCP • Entry point is GrainClient • Message Passing (Method Call), or • Observer Pattren (Pub/Sub) Orleans Client Orleans Cluster Interface s
  13. 13. SAMPLE ARCHITECTURE Orleans Cluster (Azure Cloud Service) Silo Silo Silo Azure Table Storage Shard Web API Shard Shard Request Request
  14. 14. SAMPLE ARCHITECTURE Orleans Cluster (Azure Cloud Service) Silo Silo Silo Azure Table Storage Shard Web API Shard Shard Request Request
  15. 15. THANK YOU • Orleans website • Orleans on GitHub ans • 30 min intro from Carl Hewitt who invented the Actor Model •Ask me anything: Uri Goldstein