Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modern Backends Service Fabric & Actor Model Damir Dobric, daenet.

Similar presentations


Presentation on theme: "Modern Backends Service Fabric & Actor Model Damir Dobric, daenet."— Presentation transcript:

1 Modern Backends Service Fabric & Actor Model Damir Dobric, daenet

2 Agenda Backends Today “Right” Scaling Approach
Multitier Architecture Scaling fiction Backend Limits “Right” Scaling Approach Loadbalancing Partitioning Microservices Azure Service Fabric Actor Model Mathematical Model Activation, States,..

3 “The Backend”

4 Caching helps, but.. Service Service Service Service Service Service
Client Service Client DB CACHE Service Client Service Service To scale up DB, we will need multiple nodes. But how about data consistency? Same instance of entity can be instantiated on multiple nodes. Frameworks like WCF & Co. do not solve this serious issue. Sync/Transactions?

5 Nonlinear Speed-up can even fail What is the problem?
Build 2014 5/26/2018 What is the problem? Nonlinear Additional power does not scale well Speed-up can even fail Number of nodes Speed up 5 10 Traditional models/runtime are not suitable © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

6 Scale Cube X Horizontal scale More nodes NLB Y Functional Scale
Microservices Z Data Partitioning Separate Tenants Separate by regions

7 Service Fabric Supports scale in all 3 dimensions
Client Service DATA Client Service Client Service Service DATA To scale up DB, we will need multiple nodes. But how about data consistency? Same instance of entity can be instantiated on multiple nodes. Frameworks like WCF & Co. do not solve this serious issue. Sync/Transactions?

8 Service Types Stateless State full Actor Stateless Actor State full
Anything Else Console App JAVA ASP.NET

9 Service Fabric Demo

10 Partitions and Replicas
Secondary of P1 Node Primary of P1 P61 P3 P7 P2 P5 P42 P1 P6 P3 P7 P2 P5 P4 P1 Secondary of P1 State full services are replicated P6 P3 P7 P2 P5 P42 P1 A1 Services are deployed in partitions. A1 Multiple services can be deployed in a single partition

11 Partitions and Replicas
This is a new primary n P1 Old Primary of P1 fails P6 P3 P7 P2 P5 P4 P1 P6 P3 P7 P2 P5 P4 P1 Secondary of P1 P6 P3 P7 P2 P5 P4 P1 If the node fails a new replica is automatically created. New secondary of P1

12 Actor Model

13 The Actor Model Mathematical theory of computation
Build 2014 5/26/2018 The Actor Model Mathematical theory of computation Introduced 1973 by Hewitt, Bishop, and Steiger A framework and basis for reasoning about concurrency Actors as primitives of concurrent computation © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

14 The actor model is a mathematical model of concurrent computation.
Definition The actor model is a mathematical model of concurrent computation.

15 The “Actor” Actor STATE PERSISTENCE ASYNC ONLY SINGLE THREAD EXECUTION
All methods and property getters must return a promise. Property setters are not allowed as .NET does not allow them to return a completion promise. Similarly, .NET events are not allowed. Method arguments Orleans does not eliminate execution non-determinism. Promises are resolved asynchronously and the order in which continuation delegates execute is unpredictable

16 Actor is defined by interface
Build 2014 5/26/2018 Actor is defined by interface Marker interface to indicate actor interfaces public interface IHelloActor : IActor { Task<string> SayHello(string greeting); } All actor interface operations must be asynchronous © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

17 Implementing the actor type
Build 2014 5/26/2018 Implementing the actor type public class HelloActor : Actor, IHelloActor { Task<string> SayHello(string greeting) var resp = "You said: '" + greeting + "', I say: Hello!"; return Task.SayHello(resp); } © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

18 Activation and deactivation
IHelloActor helloActor = ActorProxy.Create<IHelloActor>(actorId, appName); CLIENT public override Task OnActivateAsync() { return base.OnActivateAsync(); } public override Task OnDeactivateAsync() return base.OnDeactivateAsync(); ACTOR

19 Identifier can be of types:
Build 2014 5/26/2018 Example Identifier can be of types: {long , GUID, String} ActorId actorId = ActorId.NewId(); string applicationName = "fabric:/CalculatorActorApp"; IHelloActor helloActor = ActorProxy.Create<IHelloActor>(actorId, applicationName); double result = helloActor .AddAsync(2, 3).Result; © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

20 Single Activation Principle
Actor Actor Actor X

21 New Instance on other Node
Actor Actor X Actor Actor X

22 State vs. Stateless Stateless: State full:
public class HelloActor : Actor, IHelloActor State full: public class HelloActor : StatefullActor<MyState>, IHello [DataContract] public class State { [DataMember] public string WhateverSerializable; }

23 State persistence State Actor Persistence Provider
SQL ?

24 State replica + persistence
1 State Actor Actor Call SaveAsync() to explicitly enforce saving of the state 2 But State is also saved implicitly, after method comlettion. Persistence Provider ? await this.SaveStateAsync();

25 References Hewitt about actor model: Actor Model popular videos State Persistence Service Fabric

26 Recap Backends Today Scaling Cube Service Fabric
Multitier Architecture can lead to bottleneck Backend Limits (More nodes can mean less perf.) Scaling Cube Loadbalancing (As we know it) Partitioning (SF provides it out of the box.) Microservices (SF containers PaaS ready) Service Fabric Reliable Cluster. Can host “anything” Actor Model is cool for specific problem domains It behaves as OO, but is NOT!

27 with Service Fabric and Actor Model
Q & A Modern Backends with Service Fabric and Actor Model Damir Dobric Microsoft PTSP (Partner Technical Solution Specialist) Microsoft Most Valuable Professional Blog Twitter

28

29


Download ppt "Modern Backends Service Fabric & Actor Model Damir Dobric, daenet."

Similar presentations


Ads by Google