This session walks through incorporating Microsoft Service Fabric into your next application for zero downtime and upgradability. Microsoft have released the very same Azure Fabric smarts that look after for e.g. Azure VM management, into the Application space. Meaning your Apps can be based on the Actor model, highly distributed, scalable and in place upgrades with zero down time is now possible. Tapping into scale is key in this world of Cloud First, Device First world - can your apps handle the load? Bring the management of Azure to your application layer.
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Service Fabric – building tomorrows applications today
1. Sponsored & Brought to you by
Service Fabric – building tomorrow’s
applications today
Mick Badran
http://www.twitter.com/mickba
https://au.linkedin.com/in/mickbadran
5. • What is Service Fabric
• Demo – Stateful Actor counters
• Service Fabric Applications
• Demo – Stateful with Events
• Service Fabric Clusters
• Demo – Stateful Services – causing chaos
• Upgrading Apps with no downtime
• Demo – No Downtime Upgrade
• Wrap Up…
Agenda
7. Application development in the age of the Cloud
Features
Scalability
Manage Services
Deliver Features Faster
Create Business Value
Availability
Latency
Lifecycle
Data Integrity
Portability
8. MICROSOFT AZURE SERVICE FABRIC
A PLATFORM FOR RELIABLE, HYPERSCALE, MICROSERVICE-BASED APPLICATIONS
Microservices
Azure
Windows
Server
Linux
Hosted Clouds
Windows
Server
Linux
Service Fabric
Private Clouds
Windows
Server
Linux
High Availability
Hyper-Scale
Hybrid Operations
High Density Rolling Upgrades
Stateful services
Low Latency
Fast startup &
shutdown
Container Orchestration
& lifecycle management
Replication &
Failover
Simple
programming
models
Load balancing
Self-healingData Partitioning
Automated Rollback
Health
Monitoring
Placement
Constraints
10. 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)
11. 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
What can you build with Service Fabric
13. Azure Private Clouds
Applications composed of microservices
High Availability
Hyper-Scale
Hybrid Operations
High Density Rolling Upgrades
Stateful services
Low Latency
Fast startup &
shutdown
Container Orchestration
& lifecycle management
Replication &
Failover
Simple
programming
models
Load balancing
Self-healingData Partitioning
Automated Rollback
Health
Monitoring
Placement
Constraints
Service Fabric
14. 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)
16. 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
17. Instantiating an application
• ServiceType is “like” a .NET CLR type (class CounterServiceType)
• ApplicationType is “like” a typed Container (CounterAppType : ServiceContainer<TServiceType> 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
18. Reliable Collections
• Reliable collections make it easy to build stateful services.
• Evolution of the .NET collections for the cloud
Collections
• Single machine
• Single threaded
Concurrent
Collections
• Single machine
• Multi threaded
Reliable Collections
• Multi machine
• Replicated (HA)
• Persistence (durable)
• Asynchronous
• Transactional
19. 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)
23. 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
Node
Node
Node
Node
Node
25. Nodes failed
Machine failure detection
Time = t1
83
76 50
46
64 New Node arrived61
Time = t2
83
61
50
46
Failures Detected
cluster reconfigured
83
76
64
50
46
Time = t0
26. 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
27. 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
28. 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
30. Replication
Reads are completed
at the primary
Writes are replicated to
the write quorum of
secondaries P
S
S
S
S
WriteWrite
WriteWrite
AckAck Ack
Ack
Read
Value
Write
Ack
31. 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
X
Failed
X
Failed
37. Wrapping up…
Service Fabric provides a modern consistent framework
for your high demand Solutions.
Service Fabric provides higher fidelity management of
Solutions…
Logging, Fault tolerance, Upgrades, Restarts, Low
Latency…
SCALE!!!!!
38. Application development in the age of the Cloud
Features
Scalability
Manage Services
Deliver Features Faster
Create Business Value
Availability
Latency
Lifecycle
Data Integrity
Portability