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

Slides:



Advertisements
Similar presentations
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Advertisements

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Preface Demo A Quick Thank You How Did We Do It?
Building Scalable Web Apps with Windows Azure Name Title Microsoft Corporation.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Feature: Reprint Outstanding Transactions Report © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
Feature: Purchase Requisitions - Requester © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Co- location Mass Market Managed Hosting ISV Hosting.
Windows 7 Training Microsoft Confidential. Windows ® 7 Compatibility Version Checking.
Multitenant Model Request/Response General Model.
Feature: Purchase Order Prepayments II © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Announcing Demo Announcing.
Feature: OLE Notes Migration Utility
Feature: Web Client Keyboard Shortcuts © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Feature: SmartList Usability Enhancements © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Session 1.
Built by Developers for Developers…. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
 Rico Mariani Architect Microsoft Corporation.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Assign an Item to Multiple Sites © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Print Remaining Documents © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Connect with life Connect with life
Building ASP.NET Apps in Windows Azure Name Title Microsoft Corporation.
Windows Azure Connect Name Title Microsoft Corporation.
A Windows Azure application runs multiple instances of each role A Windows Azure application behaves correctly when.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Document Attachment –Replace OLE Notes © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
Building Social Games for Windows 8 with Windows Azure Name Title Microsoft Corporation.
Feature: Customer Combiner and Modifier © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
SQL Server SQL Azure Visual Studio“Quadrant” SQL Server Modeling Services Entity Framework ADO.NET“M”/EDM Data Services …
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
demo Instance AInstance B Read “7” Write “8”

customer.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
demo Demo.
Cloud Data Dave Campbell Technical Fellow, Microsoft.
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
Feature: Suggested Item Enhancements – Analysis and Assignment © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and.
Windows Azure SQL Data Sync Name Title Microsoft Corporation.
projekt202 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
The CLR CoreCLRCoreCLR © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
public class Foo { Bar _bar; public Foo() { this._bar = new Bar(); } public class Foo { IBar _bar; public Foo(IBar barDependency) {

Scalable by Design: The “Orleans” Actor Framework for Azure
S4 Solution Specialist Sales Summit
S4 Solution Specialist Sales Summit
Возможности Excel 2010, о которых следует знать
Title of Presentation 11/22/2018 3:34 PM
Baseline: How Are We Doing Now?
Title of Presentation 12/2/2018 3:48 PM
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
4/27/17, Bell #8 What amount of net pay has been earned this period?
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
WINDOWS AZURE A LAP AROUND PLATFORM THE Steve Marx
PENSACOLA ENERGY WORK PLAN OCTOBER 10, 2016
Title of Presentation 5/12/ :53 PM
Шитманов Дархан Қаражанұлы Тарих пәнінің
Title of Presentation 5/24/2019 1:26 PM
5/24/2019 6:44 PM 1/8/18 Bell #10 In a world governed by the gods, is there any room for human will? Do human choices make a difference? EXPLAIN © 2007.
Why is it important to follow an order of operations?
日本初公開!? Vista の新機能を実演 とっちゃん わんくま同盟 7/23/2019 9:09 AM
Title of Presentation 7/24/2019 8:53 PM
Presentation transcript:

Modern Backends Service Fabric & Actor Model Damir Dobric, daenet

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,..

“The Backend”

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?

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.

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

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?

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

Service Fabric Demo

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

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

Actor Model

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.

The actor model is a mathematical model of concurrent computation. Definition The actor model is a mathematical model of concurrent computation. https://en.wikipedia.org/wiki/Actor_model

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

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.

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.

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

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.

Single Activation Principle Actor Actor Actor X

New Instance on other Node Actor Actor X Actor Actor X

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; }

State persistence State Actor Persistence Provider SQL ?

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();

References Hewitt about actor model: https://www.youtube.com/watch?v=7erJ1DV_Tlo Actor Model popular videos https://www.youtube.com/watch?v=7erJ1DV_Tlo&list=PLhECcZb9tBx-gPymZfWjRGwnqsqmE1F2c State Persistence http://developers.de/blogs/damir_dobric/archive/2014/06/17/what-is-state-persistence-in-orleans-and-how-to-use-it.aspx Service Fabric https://azure.microsoft.com/en-gb/documentation/services/service-fabric/

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!

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 damir.dobric@daenet.com b-dadobr@microsoft.com