Actors Set the Stage for Project Orleans

advertisement
Microsoft Project Orleans
Virtual Actors Set the Stage for Performance, Reliablity, and Scale
Microsoft Certified Solutions Developer
Certified BizTalk developer
Phoenix Connected Systems User Group
Semi-active blogger (see sites)
Proponent of Cloud
Neudesic Senior Consultant
Sites
Blog:
http://bloggedbychris.com
Contact
@pcsug
PCSUG:
http://pcsug.org/
@myerscj
myers.chris.j@gmail.com
PCSUG *New (beta)
http://www.pcsug.org/
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
Teachers
Students
1
View classes
1
View classes
2
Schedule classes
2
Create classes
3
Find 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
Reference:
http://3.bp.blogspot.com
• Message driven
• Actors are addressable
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?
Introducing Virtual Actors
Actors
Silos
Teacher
Student
Class
Subject
Azure
Silos are hostable
containers for virtual
actors.
- Orleans Runtime
- Azure
- On-premise
Hybrid
Hosting
• 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
Reference:
http://research.microsoft.com/en-us/projects/orleans/
• Grains communicate through
message passing
Orleans Grains
Grain
Interface
Grain
Factory
Clients
Implements
Provides
Silos
Grains
Use
Grain
References
Orleans
Runtime
Creating the Interface
Grain
Interface
All grains
require a
grain
interface
Grain
Interface
All communications
with grains are
implemented with
Task or Task<T>
Grain
Establishes this as
a grain interface
that is referenced
through a unique
GUID
• 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
Creating the Grain
Implements our IStudent
interface and inherits from
underlying Orleas.Grain
Grain
Implementation
Orleans provides
several helpers for
managing Tasks
Generate Task<string> from
the string you wish to return
Local state only
accessible from
within grain
No state is ever
shared between
grains or clients
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)
Response time increases
exponentially once resources
begin to become strained
Approximately even at low
levels of consumption
Orleans Architecture
3-Tier Architecture
Consumption (Transactions)
Orleans does suffer
increased latency as
it scales it’s silos
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?
Download