Microsoft Project Orleans
Virtual Actors Set the Stage for Performance, Reliablity, and Scale
Contact
@myerscj@pcsug
Sites
PCSUG *New (beta)
http://www.pcsug.org/
Blog:
http://bloggedbychris.com
PCSUG:
http://pcsug.org/
Semi-active blogger (see sites)
myers.chris.j@gmail.com
Phoenix Connected Systems User Group
Certified BizTalk developerMicrosoft Certified Solutions Developer
Proponent of Cloud
Neudesic Senior Consultant
Presentation Roadmap
• Demo & Solution overview
• Overview of Actor Model
• Introducing Orleans and virtual actors!
• Basics of Orleans
• Benefits of Orleans
• Advanced topics
College Class Scheduling
Students Teachers
1 View classes
2 Schedule classes
3 Find classes
2 Create classes
1 View classes
So what’s all the hype with actors?
Well… Actors are funny!
Wait… Sorry… wrong actors.
Let’s Talk Actor Model Theory
• Concurrent digital computation
• Heavily influenced by work in the field of process calculi (or process
algebra)
• Parallel composition
• Communication
• Theory within computer science that dates back to the 1973
• Heavily influenced by packet switched networks
Actor Model
• Characteristics of actors
• Isolated
• Single-threaded
• Inherently concurrent
• Processes interact with actors
through queues
• Actors are adressable
Reference:
http://blog.kjempekjekt.com/2013/02/16/actor-model-i-f-ved-hjelp-av-mailboxprocessor/
Actor Model – Mailbox Example
• Characteristics of actors
• Isolated state
• Data locality
• Locality
• There is no simultaneous
change in multiple
locations
• Message driven
• Actors are addressableReference:
http://3.bp.blogspot.com
Actor Models and Frameworks
• .NET
• Actor Framework
• NAct
• Retlang
• PostSharp
• Akka.NET
• Java and Skala
• Akka (toolkit)
• Erlang (Actor programming languages)
• Common complaints
• Actors are often not usefully typed
• Actors don’t always compose very well
Thank you Chris for the walk down memory lane, but…
What’s all this have to do with Orleans?
Actors
Introducing Virtual Actors
Teacher Student
Class Subject
Silos Silos are hostable
containers for virtual
actors.
- Orleans Runtime
- Azure
- On-premise
Hybrid
Hosting
Azure
• Virtual actors are called grains
• Concurrent components
• State
• Behavior
• Actor-based
• Silos communicate through
Orleans conduit
• Silos are hosted via Orleans
runtime
• Azure
• Windows
• Applications
• Grains communicate through
message passingReference:
http://research.microsoft.com/en-us/projects/orleans/
Orleans Grains
Grains
Grain
Interface
Silos
Implements
Provides
Grain
Factory
Grain
References
Use
Clients
Orleans
Runtime
Creating the Interface
Establishes this as
a grain interface
that is referenced
through a unique
GUID
All communications
with grains are
implemented with
Task or Task<T>
All grains
require a
grain
interface
• Grain interface shared between
client and server
• Implementations of grains
inherit from a grain interface
• Grains always return either Task
or Task<T>
• Grains are identified by a unique
identifier:
• IGrainWithGuidKey
• IGrainWithStringKey
• IGrainWithLongKey
Grain
Grain
Interface
Grain
Interface
Creating the Grain
Implements our IStudent
interface and inherits from
underlying Orleas.Grain
Grain
Implementation
Orleans provides
several helpers for
managing Tasks
Local state only
accessible from
within grain
No state is ever
shared between
grains or clients
Generate Task<string> from
the string you wish to return
Running Your First Demo
• Download and install the Orleans SDK
• May also want to grab the latest Azure SDK at this time
• Create a grain interface project
• Create a grain collection project
• Create a DevTest silo using the VS project template
• Create a grain interface and corresponding grain
• Configure the client and server configuration files
• Run it!
Demo Time
Creating a Standalone Grain Dev/Test Silo
Demo Time
Implementing Grains in Azure
Recap
• Actors are isolated single-threaded components
• Orleans grains are like actors, but have differences (virtual actors)
• Grains encapsulate both state and behavior
• Developer interaction with grains is very familiar
• Object instances are similar grain references
• Runtime handles complexities that other actor frameworks do not:
• Actor placement and load balancing
• Deactivation of unused actors
• Actor recovery after server failures
• Indirection handled via a distributed directory
This all looks really cool, but come on Chris…
What’s the point? Why should I use this?
Here’s Why
• Grains are
• Low latency
• High availability
• Supremely scalable
• Promote reliability
• Extremely performant (will be discussed later)
• 3-tier architecture has limitations
• Throughput limits of the storage layer
• Storage layer has limited scalability due
• Storage layer that has to be consulted for every request
Orleans vs. Multi-Server 3-Tier
Time(Response)
Consumption (Transactions)
Orleans Architecture
3-Tier Architecture
Response time increases
exponentially once resources
begin to become strained
Orleans does suffer
increased latency as
it scales it’s silos
Approximately even at low
levels of consumption
Come on… Let’s get into some more Advanced
topics already!!!
Demo Time
Implementing Grain Persistence
Demo Time
Passing Grain References
Orleans is Dynamic
• Providers
• Azure Table
• SQL Server
• Memory (Grain)
• Roll your own
• Custom Serializers
• Runtime Monitoring
• Performance counters
• Silo statistics and metrics tables
• Liveness Provider
• Membership Table Grain
• Azure Table
• SQL Server
• Hosting
• Stand-alone Silo
• On-Premise Deployment
• Azure
You may feel at this point that the framework is too new…
Has it really been tested in the field?
Who’s really using this?
Questions?

Actors Set the Stage for Project Orleans

  • 1.
    Microsoft Project Orleans VirtualActors Set the Stage for Performance, Reliablity, and Scale
  • 2.
    Contact @myerscj@pcsug Sites PCSUG *New (beta) http://www.pcsug.org/ Blog: http://bloggedbychris.com PCSUG: http://pcsug.org/ Semi-activeblogger (see sites) myers.chris.j@gmail.com Phoenix Connected Systems User Group Certified BizTalk developerMicrosoft Certified Solutions Developer Proponent of Cloud Neudesic Senior Consultant
  • 3.
    Presentation Roadmap • Demo& Solution overview • Overview of Actor Model • Introducing Orleans and virtual actors! • Basics of Orleans • Benefits of Orleans • Advanced topics
  • 4.
    College Class Scheduling StudentsTeachers 1 View classes 2 Schedule classes 3 Find classes 2 Create classes 1 View classes
  • 5.
    So what’s allthe hype with actors?
  • 6.
    Well… Actors arefunny! Wait… Sorry… wrong actors.
  • 7.
    Let’s Talk ActorModel Theory • Concurrent digital computation • Heavily influenced by work in the field of process calculi (or process algebra) • Parallel composition • Communication • Theory within computer science that dates back to the 1973 • Heavily influenced by packet switched networks
  • 8.
    Actor Model • Characteristicsof actors • Isolated • Single-threaded • Inherently concurrent • Processes interact with actors through queues • Actors are adressable Reference: http://blog.kjempekjekt.com/2013/02/16/actor-model-i-f-ved-hjelp-av-mailboxprocessor/
  • 9.
    Actor Model –Mailbox Example • Characteristics of actors • Isolated state • Data locality • Locality • There is no simultaneous change in multiple locations • Message driven • Actors are addressableReference: http://3.bp.blogspot.com
  • 10.
    Actor Models andFrameworks • .NET • Actor Framework • NAct • Retlang • PostSharp • Akka.NET • Java and Skala • Akka (toolkit) • Erlang (Actor programming languages) • Common complaints • Actors are often not usefully typed • Actors don’t always compose very well
  • 11.
    Thank you Chrisfor the walk down memory lane, but… What’s all this have to do with Orleans?
  • 12.
    Actors Introducing Virtual Actors TeacherStudent Class Subject Silos Silos are hostable containers for virtual actors. - Orleans Runtime - Azure - On-premise Hybrid Hosting Azure
  • 13.
    • Virtual actorsare called grains • Concurrent components • State • Behavior • Actor-based • Silos communicate through Orleans conduit • Silos are hosted via Orleans runtime • Azure • Windows • Applications • Grains communicate through message passingReference: http://research.microsoft.com/en-us/projects/orleans/
  • 14.
  • 15.
    Creating the Interface Establishesthis as a grain interface that is referenced through a unique GUID All communications with grains are implemented with Task or Task<T> All grains require a grain interface • Grain interface shared between client and server • Implementations of grains inherit from a grain interface • Grains always return either Task or Task<T> • Grains are identified by a unique identifier: • IGrainWithGuidKey • IGrainWithStringKey • IGrainWithLongKey Grain Grain Interface Grain Interface
  • 16.
    Creating the Grain Implementsour IStudent interface and inherits from underlying Orleas.Grain Grain Implementation Orleans provides several helpers for managing Tasks Local state only accessible from within grain No state is ever shared between grains or clients Generate Task<string> from the string you wish to return
  • 17.
    Running Your FirstDemo • Download and install the Orleans SDK • May also want to grab the latest Azure SDK at this time • Create a grain interface project • Create a grain collection project • Create a DevTest silo using the VS project template • Create a grain interface and corresponding grain • Configure the client and server configuration files • Run it!
  • 18.
    Demo Time Creating aStandalone Grain Dev/Test Silo
  • 19.
  • 20.
    Recap • Actors areisolated single-threaded components • Orleans grains are like actors, but have differences (virtual actors) • Grains encapsulate both state and behavior • Developer interaction with grains is very familiar • Object instances are similar grain references • Runtime handles complexities that other actor frameworks do not: • Actor placement and load balancing • Deactivation of unused actors • Actor recovery after server failures • Indirection handled via a distributed directory
  • 21.
    This all looksreally cool, but come on Chris… What’s the point? Why should I use this?
  • 22.
    Here’s Why • Grainsare • Low latency • High availability • Supremely scalable • Promote reliability • Extremely performant (will be discussed later) • 3-tier architecture has limitations • Throughput limits of the storage layer • Storage layer has limited scalability due • Storage layer that has to be consulted for every request
  • 23.
    Orleans vs. Multi-Server3-Tier Time(Response) Consumption (Transactions) Orleans Architecture 3-Tier Architecture Response time increases exponentially once resources begin to become strained Orleans does suffer increased latency as it scales it’s silos Approximately even at low levels of consumption
  • 24.
    Come on… Let’sget into some more Advanced topics already!!!
  • 25.
  • 26.
  • 27.
    Orleans is Dynamic •Providers • Azure Table • SQL Server • Memory (Grain) • Roll your own • Custom Serializers • Runtime Monitoring • Performance counters • Silo statistics and metrics tables • Liveness Provider • Membership Table Grain • Azure Table • SQL Server • Hosting • Stand-alone Silo • On-Premise Deployment • Azure
  • 28.
    You may feelat this point that the framework is too new… Has it really been tested in the field? Who’s really using this?
  • 30.