11 Janvier 2016
Groupe Azure
Sujet: Développer des microservices avec Service Fabric
Conférienciers: Stephane Lapointe, MVP Azure & Alexandre Brisebois, TSP Azure Microsoft
Une soirée complète sur Service Fabric! Nous débuterons par la base en explorant l'architecture de Service Fabric et les modèles de programmation qu'il propose, les "Reliable Actors" et "Reliable Services" en mettant l'emphase sur le modèle Acteurs.
Comme il est plus agréable d'apprendre avec des exemples, nous verrons le cycle de vie complet d'une application au sein de Service Fabric et les outils offert par la plateforme; développement, packaging, déploiement, tests de stabilités, mises à jour et maintenance sont les sujets que nous explorerons.
À la fin de cette rencontre, vous aurez les connaissances nécessaires pour mener à bien un projet de microservices en utilisant les acteurs dans Service Fabric.
Stephane Lapointe & Alexandre Brisebois: Développer des microservices avec Service Fabric
1.
2.
3.
4.
5.
6. 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
Actor programming model
13. Build and operate services at scale
Agility - faster delivery of features & updates
Better resource utilization
14. Simpler to design
Faster calls between components
Testing a single product
Tightly coupled within the tiered layers
Harder to perform fixes and upgrades
15. Scalability + fast spinup
Encourage simpler business functionality encapsulation
Isolated components with independent lifecycle
Fit the lean startup approach – build, measure, learn, iterate
Increased number of separate entities
More complex deployments
Network latency between microservices
Easy to endup with a performance nightmare
16.
17.
18. Stateless microservice
Has either no state or it can be retrieved from an external store
There can be N instances
e.g. web frontends, protocol gateways, Azure Cloud Services etc.
Stateful microservice
Maintain hard, authoritative state
N consistent copies achieved through replication and local persistence
e.g. database, documents, workflow, user profile, shopping cart etc.
19.
20. A platform for reliable, hyperscale, microservice-based applications
Azure
Windows
Server
Linux
Hosted Clouds
Windows
Server
Linux
Service Fabric
Private Clouds
Windows
Server
Linux
High Availability
Hyper-Scale
Hybrid Operations
High Density
microservices
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
21.
22. Service discovery Reliability, Availability,
Replication, Service
Orchestration
Application lifecycle
Fault Inject,
Test in production
Federates a set of nodes to form a consistent scalable fabric
Secure point-to-point communication
Deployment,
Upgrade and
Monitoring
microservices
23. L+S (logic + state) that is independently versioned,
deployed, and scaled
Has a unique name that can be resolved
e.g. fabric:/myapplication/myservice
Interacts with other microservices over well defined
interfaces and protocols like REST
Remains always logically consistent in the presence of
failures
Hosted inside a “container” (code + config)
Can be written in any language and framework
.NET, node.js, Java VMs, any EXE
24. A set of independent
machines; physical or
virtual
25. A set of machines that
Service Fabric stitches
together to form a
cluster
Clusters can scale to
1000s of machines
Node
Node
Node
Node
Node
Node
29. Each service is backed by replica set to make its
internal state reliable
All replicas are logically consistent – meaning all
replicas see the same linearized 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.
31. Massive scale
No difference between dev and production
Executables & frameworks can be .NET and/or OSS
Stateless or Stateful (micro)services
Simplify application design, stateful service instead of
caches/queues
32. Deploy applications in seconds
Write once, deploy almost anywhere
Higher density than VM
Multiple versions of the same application side by side
No downtime for breaking & nonbreaking upgrades
33. Management via .NET APIs, PowerShell or REST
Upgrade and patch specific microservices
OOB health & diagnostic
Automatically adjust to scale up or scale down
Multiple version of the same application side by side,
each independently upgradable
Self-healing resource balancer
34.
35. Service Fabric Applications
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
36. Application
Package
Unit of
• Lifetime
• Versioning
• Isolation
LiveQnA.API
Service type
LiveQnA
Extensions type
LiveQnA
Pkg
Code Config
LiveQnA
Extensions
Pkg
Application Type
39. 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
40. 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
49. Write services that are reliable, available, scalable
and provide consistency
More control over data partitioning so you can
determine data relationships and consistency
requirements between chunks of state
Multithreaded
Use Reliable Collections to persist state
More likely to BYO transport (WCF, WebAPI, ..)
50. Collections
• Single Threaded
Concurrent
Collections
• Multi-Threaded
Reliable
Collections
• Multi-Node
• Replicated (HA)
• Persistence
Option
• Asynchronous
• Transactional
Dictionary<TKey, TValue> ConcurrentDictionary<TKey, TValue> ReliableDictionary<TKey, TValue>
Single Machine Multi-Machine
Use our replicated datastructures or build your own
51. Data is replicated and durably stored on multiple replicas.
Atomically update one or more collections using transactions.
Reads are repeatable within the transaction.
Enumerations are snapshot based.
Supports LINQ.
IReliableQueue<T>IReliableDictionary<K,V>
52. Reliable Actors APIs Reliable Services APIs
Your problem space involves many small independent
units of state and logic
You need to maintain logic across multiple components
You want to work with single-threaded objects while still
being able to scale and maintain consistency
You want to use reliable collections (like .NET Dictionary
and Queue) to store and manage your state
You want the framework to manage the concurrency and
granularity of state
You want to control the granularity and concurrency of
your state
You want the platform to manage communication for
you
You want to manage the communication and control the
partitioning scheme for your service
57. Generates faults across the entire Service Fabric
cluster
Compresses faults generally seen in months or years
to a few hours
Combination of interleaved faults with the high fault
rate finds corner cases that are otherwise missed
Leads to a significant improvement in the code
quality of the service
58.
Restart a node
Restart a deployed code package
Remove a replica
Restart a replica
Move a primary replica (optional)
Move a secondary replica (optional)
Failover test
59.
Restart a deployed code package where the partition is hosted
Remove a primary/secondary replica or stateless instance
Restart a primary secondary replica (if a persisted service)
Move a primary replica
Move a secondary replica
Restart the partition
61. Stateless services
A service that has state where the state is persisted to external storage, such as Azure databases or
Azure storage
Existing web (ASP.NET) and worker role applications
Stateful services
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
62. Are microservices for me?
Use Service Fabric to Reduce the complexities of
building applications with the microservice
approach
Start small, scale when needed, deprecate
services, add new ones, evolve with customer
usage, that’s the approach.
63. Built micro-services using Reliable Actors and
Reliable Services APIs
Achieve Data Reliability through Stateful Actors and
Reliable Collections
Scale-out using partitioning
64. Download the Service Fabric developer SDK
http://aka.ms/ServiceFabric
Download the samples from GitHub
http://aka.ms/ServiceFabricSamples
Learn from the tutorials and videos
http://aka.ms/ServiceFabricDocs
Provide feedback
http://aka.ms/ServiceFabricForum
http://stackoverflow.com/questions/tagged/azure-service-fabric
Twitter hastag #AzureServiceFabric