Mick Badran Using Microsoft Service Fabric to build your next Solution with zero downtime – Lvl 300 CLD32 5
MOQdigital Azure MVP, Insider & Doing mo-vember Who Am I
Agenda What is Service Fabric Demo – Stateless and Stateful counters Service Fabric Applications Demo - Reliable Service API Stateful Word count service Service Fabric Clusters Demo – Stateful Microservices – causing chaos Upgrading Apps with no downtime Demo – No Downtime Upgrade Wrap Up…
Application development in the age of the Cloud Features Scalability Manage Services Deliver Features Faster Create Business Value Availability Latency Lifecycle Data Integrity Portability
Microsoft Azure Service Fabric A platform for reliable, hyperscale, microservice-based applications
Battle-hardened for over 5 years
What is a microservice? Is (logic + state) that is independently versioned, deployed, and scaled Has a unique name that can be resolved e.g. fabric:/myapplication/myservice Call other Microservices Remains always logically consistent in the presence of failures Hosted inside a “container” (code + config)
What can you build with Service Fabric Stateless applications A service that has state where the state is persisted to external storage, such as Azure databases or Azure storage e.g. Existing web (ASP.NET) and worker role applications Stateful applications Reliability of state through replication and local persistence Reduces latency Reduces the complexity and number of components in traditional three tier architecture Existing apps written with other frameworks node.js, Java VMs, any EXE
Installing Service Fabric
Reliable Actor API Build reliable stateless and stateful objects with a virtual Actor Programming Model Suitable for applications with multiple independent units of state and compute Automatic state management and turn based concurrency (single threaded execution)
Demo: Stateful and Stateless Counters
Application Package Unit of Lifetime Versioning Isolation Counter Service type Counter WebApp type Defining applications and services Counter Service Pkg Code Config Counter WebApp Pkg Application Type
Instantiating an application ServiceType is “like” a.NET CLR type (class CounterServiceType) ApplicationType is “like” a typed Container (CounterAppType : ServiceContainer where TServiceType is CounterServiceType, ServiceType2 ApplicationInstance is an instance of the ApplicationType and has an unique name “fabric:/CounterApplication” Each service instance has a unique name in the “namespace” of the application “fabric:/CounterApplication/CounterService” Service Package B Service Package A Service Package B Service Package A Service Package B Service Package A Service Package B Service Package A
Reliable Collections Reliable collections make it easy to build stateful services. Evolution of the.NET collections for the cloud
Reliable Services API Build stateless services using existing technologies such as ASP.NET Build stateful services using reliable collections Manage the concurrency and granularity of state changes using transactions Communicate with services using the technology of your choice ( e.g WebAPI, WCF )
Demo: Reliable Service API Stateless Word count service
Cloud Services Azure Tables/NoSQL Reliable Azure Queue Service Fabric (Stateful) Word count service Cloud Service vs Stateful Service Fabric
Demo: Reliable Service API StateFUL Word count service
A set of machines that Service Fabric stitches together to form a cluster Clusters can scale to 1000s of machines Cluster: A federation of machines Node
Service Fabric Subsystems Microservices
Nodes failed Machine failure detection Time = t New Node arrived 61 Time = t Failures Detected cluster reconfigured Time = t 0
Queues Storage 3-Tier service pattern Front End (Stateless Web) Stateless Middle-tier Compute Cache Scale with partitioned storage Increase reliability with queues Reduce read latency with caches Manage your own transactions for state consistency Many moving parts each managed differently Load Balancer
Stateful Middle-tier Compute Stateful services: Simplify design, reduce latency Front End (Stateless Web) data stores used for analytics and disaster recovery Application state lives in the compute tier Low Latency reads and writes Partitions are first class for scale-out Built in transactions Fewer moving parts Load Balancer
Stateful microservices are reliable and consistent Each service is backed by replica set to make its internal state reliable All replicas are logically consistent – meaning all replicas see the same linearised order of read and write operations to initial state Read-Write quorums are supported and are dynamically adjusted Replica set is dynamically reconfigured to account for replica arrivals and departures
Stateful microservice Application Package replication
Replication Reads are completed at the primary Writes are replicated to the write quorum of secondaries P S S S S Write Ack Read Value Write Ack
Reconfiguration Types of reconfiguration Primary failover Removing a failed secondary Adding recovered replica Building a new secondary Replica States None Idle Secondary Active Secondary Primary P S S S S S Must be safe in the presence of cascading failures B P Failed
Application: logical grouping of microservices Application
Application Lifecycle Management Provisioning and deployment of fellow microservices Upgrade microservices without loss of availability Monitor microservices Interface with machine management layer for autoscale and initiating reboot, reimage, and repair actions Provide operational insight into aggregate utilisation – inventory, performance counters/metrics, etc. – for capacity planning
Upgrading Services with zero downtime Application Package
Application development in the age of the Cloud Features Scalability Manage Services Deliver Features Faster Create Business Value Availability Latency Lifecycle Data Integrity Portability
Mick
Continue your Ignite learning path Visit Microsoft Virtual Academy for free online training visit Visit Channel 9 to access a wide range of Microsoft training and event recordings Head to the TechNet Eval Centre to download trials of the latest Microsoft products