In the report, mechanisms of communication between microservices within a cluster were addressed, as well as multi-tier versioning, from the application level up to services and configurations. Also, pros and cons of Stateful Services were
discussed and state management in Stateful Services reviewed. There were shared practical tips on minimizing effort while using Microsoft Service Fabric on a daily basis.
This presentation by Andriy Gnennyy, Senior Consultant, leader Cloud-practice at GlobalLogic Kharkiv, was delivered at GlobalLogic Kharkiv MS TechTalk #3 on April 24, 2018.
5. 5
Options for Microservices
Azure Container Service (AKS)
Azure Functions Azure Service Fabric Azure App Service (Web Apps)
Azure Cloud Services
Azure Container Instances
6. 6
Best option for complex .Net (Core) Microservices
Azure Service Fabric
• Secure, flexible and robust
• Ready to scale & to handle extra complexity
• Incorporates state management
• Cross-platform engine
• Becomes open source (work in progress)
• And more...
11. 11
Reverse Proxy Role
N nodes x M services + Dynamic Ports + Port Sharing + Partitions + … = Issue???
12. 12
Is HTTP the Only Option?
Consider Service Remoting. … and use V2
• Integrated service discovery
• Lightweight & fast
• Easy to configure
• Supports custom serialization
• Security based on certificates
ServiceA
IServiceA
ServiceAProxyServiceB
15. 15
Let Service Own its Data: “Singleton” - Part 1
Register()
Registration
Service
(stateless)
Select Count
Add New Row
DatabaseGetCount()
16. 16
Let Service Own its Data: “Singleton” - Part 2
Register()
Registration
Service
(stateless)
Select Count
Add New Row
DatabaseGetCount()
Count Service
(stateful)
State Persisted
and Replicated by
Service Fabric
GetCount()Increment()
17. 17
Let Service Own its Data: Actors
IIndexer
ISearch
Batch of points
Next point
Interface Stateless Service Stateful Actor
Pre-processing &
Normalization
Clusterization &
Storage
Search via
Map & Reduce
Prediction
19. 19
Where is My State?
• Manage failure domains
• Follow replica recommendations
• Remember that there is no
backup by default!
• Externalize state
• Consider approach when the state
is rebuildable
• Consider cluster periodic backup
(Preview)
• Incorporate backuprestore into
the service (Advanced)
22. 22
A1: 1.0.0
Versioning in Action
S1: 1.0.0
C1: 1.0.0
S2: 1.0.0
C2: 1.0.0
S3: 1.0.0
C3: 1.0.0
• 3 services in the application
• Single application instance
• Initial version deployed
• Services handle requests
23. 23
A1: 1.0.0
Versioning in Action
S1: 1.0.0
C1: 1.0.0
S2: 1.0.0
C2: 1.0.0
S3: 1.0.0
C3: 1.0.0
A1: 2.0.0
S1: 1.0.0
C1: 1.0.0
S2: 2.0.0
C2: 1.0.0
S3: 1.0.0
C3: 1.0.0
• Service S2 is now version 2.0.0
• Application is now version 2.0.0
• Upgrade executed
• S1 and S3 are still running
• S2 started from the new package
24. 24
A1: 1.0.0
Versioning in Action
S1: 1.0.0
C1: 1.0.0
S2: 1.0.0
C2: 1.0.0
S3: 1.0.0
C3: 1.0.0
A1: 2.0.0
S1: 1.0.0
C1: 1.0.0
S2: 2.0.0
C2: 1.0.0
S3: 1.0.0
C3: 1.0.0
• S3 config C3 is now version 2.0.0
• Application is now version 3.0.0
• Upgrade executed
• S1 and S2 are still running
• S3 restarted with configuration
from the new package
A1: 3.0.0
S1: 1.0.0
C1: 1.0.0
S2: 2.0.0
C2: 1.0.0
S3: 1.0.0
C3: 2.0.0
25. 25
A1: 1.0.0
Running Versions Side-by-Side
S1: 1.0.0
C1: 1.0.0
S2: 1.0.0
C2: 1.0.0
S3: 1.0.0
C3: 1.0.0
• SF can run multiple app instances
• Same or different version
• Custom instance parameters
• Testing side-by-side
• Advanced upgrade type
• Consider Reverse Proxy
A1: 1.5.0
S1: 1.2.0
C1: 1.2.0
S2: 1.5.0
C2: 1.2.0
S3: 1.5.0
C3: 1.5.1
Instance 1
Instance 2
26. 26
Safe Upgrades
• Proper discovery & retries
• Back/forward state compatibility
• Interface versioning
• Test!
Service Fabric is smart, but it is better to remember the following:
28. 28
Simple CICD Pipeline for Service Fabric
Image Store
API
Cluster Manager
Health Manager
Hosting Subsystem
29. 29
Service Fabric Upgrade Flexibility
Upgrade Aspect Default Behavior Other Opportunities
Mode Monitored Unmonitored Manual, Unmonitored Auto
Flow Rolling Upgrade at once with single UD
Health Checks Yes Custom policy, Unmonitored mode
Compatibility Backward and Forward Upgrade in stages to introduce breaking
changes
Rollback Automatic Switch to Unmonitored Manual