32
Massively Scalable .NET Web Services w/ Project Orleans DECEMBER 5TH 2016 – NEWMAN SCOTT HUNTER [email protected] [email protected]

Massively Scaleable .NET Web Services with Project Orleans

Embed Size (px)

Citation preview

Page 1: Massively Scaleable .NET Web Services with Project Orleans

Massively Scalable .NET Web Services w/ Project OrleansDECEMBER 5TH 2016 – NEWMAN SCOTT [email protected]@EA.COM

Page 2: Massively Scaleable .NET Web Services with Project Orleans

Who is this guy?

Page 3: Massively Scaleable .NET Web Services with Project Orleans

Agenda• Introducing Orleans• Basic Actor Concepts• Orleans Terminology• Orleans in Action• Use Cases and Gotchas

Page 4: Massively Scaleable .NET Web Services with Project Orleans

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 Virtual

Actors

Page 5: Massively Scaleable .NET Web Services with Project Orleans

What are Actors?

Page 6: Massively Scaleable .NET Web Services with Project Orleans

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.

Page 7: Massively Scaleable .NET Web Services with Project Orleans

Thread One Thread Two Thread Three

Memory

Page 8: Massively Scaleable .NET Web Services with Project Orleans

Memory

Page 9: Massively Scaleable .NET Web Services with Project Orleans

Memory

Page 10: Massively Scaleable .NET Web Services with Project Orleans

Memory

Thread A Thread B

Page 11: Massively Scaleable .NET Web Services with Project Orleans

Orleans Terminology

Page 12: Massively Scaleable .NET Web Services with Project Orleans

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*• Because Actors only execute messages stored in their inbox

and can only send messages to other Actors via their inboxes, issues with concurrency are minimized*

Page 13: Massively Scaleable .NET Web Services with Project Orleans

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

Page 14: Massively Scaleable .NET Web Services with Project Orleans

Orleans Terminology

• Each Orleans ‘Actor’ is a ‘Grain’. A grain SHOULD correspond to a discrete unit.

Page 15: Massively Scaleable .NET Web Services with Project Orleans

Orleans Terminology

• Each ‘Grain’ receives one ‘Turn’ when executing awaiting messages, and may send messages to other ‘Grain’s

Page 16: Massively Scaleable .NET Web Services with Project Orleans

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

Page 17: Massively Scaleable .NET Web Services with Project Orleans

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.

Page 18: Massively Scaleable .NET Web Services with Project Orleans

Orleans Terminology

• Each Silo has a client access port, so requests to any grain can be addressed to any silo.

Page 19: Massively Scaleable .NET Web Services with Project Orleans

Orleans Terminology

IIS

Page 20: Massively Scaleable .NET Web Services with Project Orleans

Orleans in Action

Page 21: Massively Scaleable .NET Web Services with Project Orleans

Orleans in Action• Three core components• Interface• Implementation• Access

Page 22: Massively Scaleable .NET Web Services with Project Orleans

Orleans in Action

Page 23: Massively Scaleable .NET Web Services with Project Orleans

Orleans in Action• Possible Grain Keys (As Defined by the Interface)• Guid• Long• String• ‘Compound Primary’• Hash of a GUID and a Long

Page 24: Massively Scaleable .NET Web Services with Project Orleans

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.

Page 25: Massively Scaleable .NET Web Services with Project Orleans

Orleans in ActionUse 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)

Page 26: Massively Scaleable .NET Web Services with Project Orleans

Orleans in Action

Page 27: Massively Scaleable .NET Web Services with Project Orleans

Orleans in Action

Page 28: Massively Scaleable .NET Web Services with Project Orleans

Use Cases and Gotchas

Page 29: Massively Scaleable .NET Web Services with Project Orleans

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.

Page 30: Massively Scaleable .NET Web Services with Project Orleans

Use Cases and GotchasScaling 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.

Page 31: Massively Scaleable .NET Web Services with Project Orleans

Use Cases and GotchasOrleans + 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.

Page 32: Massively Scaleable .NET Web Services with Project Orleans

More InfoOrleans Homepagehttps://dotnet.github.io/orleans/

Halo 4 Web Services in Orleanshttps://www.youtube.com/watch?v=rEa2nQrpEhc

Orleans MSR Home Pagehttps://www.microsoft.com/en-us/research/project/orleans-virtual-actors/

Azure Reliable Actorshttps://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-actors-get-started

Java Orbithttps://github.com/orbit/orbit

Newman Scott [email protected]@ea.com