30
Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Embed Size (px)

Citation preview

Page 1: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Microsoft Project Orleans

Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Page 2: 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)

[email protected]

Phoenix Connected Systems User Group

Certified BizTalk developerMicrosoft Certified Solutions Developer

Proponent of Cloud

Neudesic Senior Consultant

Page 3: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Presentation Roadmap

• Demo & Solution overview• Overview of Actor Model• Introducing Orleans and virtual actors!• Basics of Orleans• Benefits of Orleans• Advanced topics

Page 4: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

College Class Scheduling

Students Teachers

1 View classes

2 Schedule classes

3 Find classes

2 Create classes

1 View classes

Page 5: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

So what’s all the hype with actors?

Page 6: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Well… Actors are funny!Wait… Sorry… wrong actors.

Page 7: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

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

Page 8: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

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/

Page 9: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

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

Page 10: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

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

Page 11: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Thank you Chris for the walk down memory lane, but… What’s all this have to do with Orleans?

Page 12: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Actors

Introducing Virtual Actors

Teacher Student

Class Subject

Silos Silos are hostable containers for virtual actors.- Orleans Runtime- Azure- On-premise

Hybrid Hosting

Azure

Page 13: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

• 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/

Page 14: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Orleans Grains

Grains

Grain Interface

Silos

ImplementsProvides

Grain Factory

Grain References

Use

Clients

Orleans Runtime

Page 15: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

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

GrainGrain

InterfaceGrain

Interface

Page 16: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

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

Page 17: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

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!

Page 18: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Demo TimeCreating a Standalone Grain Dev/Test Silo

Page 19: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Demo TimeImplementing Grains in Azure

Page 20: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

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

Page 21: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

This all looks really cool, but come on Chris… What’s the point? Why should I use this?

Page 22: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

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

Page 23: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Orleans vs. Multi-Server 3-TierTi

me

(Res

pons

e)

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

Page 24: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Come on… Let’s get into some more Advanced topics already!!!

Page 25: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Demo TimeImplementing Grain Persistence

Page 26: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Demo TimePassing Grain References

Page 27: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

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

Page 28: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

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?

Page 29: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale
Page 30: Microsoft Project Orleans Virtual Actors Set the Stage for Performance, Reliablity, and Scale

Questions?