Service Fabric Private Clouds

Creating highly available and
resilient Microservices on
Microsoft Azure Service Fabric
Mahesh Krishnan
CLD334
Agenda
Why use microservices?
Azure Service Fabric Platform – An introduction
Service Fabric Programming model
Reliable Actors
Reliable Services
Wrap up
Traditional Monolithic approach
A monolithic application has most of its functionality within
a single process that is commonly componentized with
libraries
Scales by cloning the app on multiple servers/VMs/
containers
Microservices approach
Separates functionality into separate smaller services
Uses a standard communication protocol
Scales out be deploying each service independently
creating instances of these services across servers/VMs
containers
Why use microservices?
Microsoft Azure Service Fabric
A platform for reliable, hyperscale, microservice-based applications
microservices
High Availability
Simple
programming
models
Hybrid Operations
High Density
Hyper-Scale
Windows
Server
Data Partitioning
Rolling Upgrades
Automated Rollback
Service Fabric
Low Latency
Stateful services
Health
Monitoring
Placement
Constraints
Container Orchestration
& lifecycle management
Fast startup &
shutdown
Load balancing
Windows
Server
Linux
Azure
Self-healing
Replication & Failover
Linux
Hosted Clouds
Windows
Server
Linux
Private Clouds
Service Fabric cluster with microservices
App1
App2
Types of Microservices
Stateless Microservices
Stateful Microservices
Service fabric applications
Actor programming model
Introduced in 1973!
An actor is the fundamental unit of computation
Does some processing
Holds state
Communicates with other actors
Similar to objects in OOP
Reliable Actors API
Build reliable stateless and stateful objects using a
virtual Actor programming model
Suitable for applications with multiple independent units
of scale and compute
Automatic state management and turn based concurrency
Reliable Actors
Actors have an lD that maps to an object
Service Fabric manages nodes and can transparently
move actors amongst them (provides HA and scale)
Actor methods run via turn based concurrency
Getting started
Download the Service Fabric Download
Ensure PowerShell is installed and right execution
policies set up
Run the DevClusterSetup.ps1script to start local cluster
Actor lifecycle - Activation
If actor is not active, a new actor is created
Its state is then loaded (for stateful actors)
OnActivateSync method is called
Added to Active Actors table
Actor lifecycle - Deactivation
Unused actors removed from the Active Actors table
OnDeactivateSync method is called on Actor
Once deactivated, objects are garbage collected by CLR
Actor lifecycle – more concepts
Scan interval – Time interval between successive scans
by Actor runtime for inactive actors (Default: 60 seconds)
Idle timeout – Time an actor can be idle before it is
deactivated (Default: 60 seconds)
ActorGarbageCollection attribute used to change defaults
Reliable Services API
Write services that are reliable, available, scalable
and provide consistency
Use Reliable Collections to persist state
Communicate using tech of your choice (WCF, WebAPI, ..)
Reliable Collection
Can be used to create Stateful services.
Features:
Multi-machine
Replicated (HA)
Persistance (durable)
Asynchrounous
Transactional
Getting started…
Only two methods you need to implement to get started.
CreateCommunicationListener – Method where the
communication stack for the service is defined
RunAsync – This is where the Service runs the business
logic – similar to WorkerRole’s Run method
Wrap up…
Service Fabric is the next generation of PaaS that can
be used to create microservices
Has 2 programming models:
Reliable Actor API
Reliable Service API
Can create either stateful or stateless services
Availability, Scalability, load balancing, etc comes OOB
My Ignite
Continue your Ignite learning path
Visit Microsoft Virtual Academy for free online training visit
https://www.microsoftvirtualacademy.com
Visit Channel 9 to access a wide range of Microsoft
training and event recordings https://channel9.msdn.com/
Head to the TechNet Eval Centre to download trials of the latest
Microsoft products http://Microsoft.com/en-us/evalcenter/
© 2015 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.
MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
AS TO THE INFORMATION IN THIS PRESENTATION.