SlideShare a Scribd company logo
1 of 31
Download to read offline
Dual Write Strategies for
Microservices
Bilgin Ibryam
@bibryam
Product Manager
Red Hat
About me
2
▸ Product Manager at Red Hat
▸ Former Principal Architect
▸ Committer at Apache Camel
▸ Author
・ Camel Design Patterns
・ Kubernetes Patterns
▸ @ bibryam
▸ https://www.ofbizian.com
There is a catch
3
Challenges with legacy applications
▸ Frequent deployment is difficult
▸ Obstacles to scaling development
▸ Scaling the application can be difficult
Modern application benefits
▸ Greater team autonomy
▸ Reliability, scalability, and other abilities
▸ Reduce time to market
The dual-write problem
4
Dual-write challenge behind the scene
▸ Updating more than one resources
▸ Reliable inter-service communication
▸ Coordinating long-running, business transactions
▸ Recovery from failed distributed transaction
▸ Implementing idempotent operations
▸ Scaling with increasing data volume
Dual write strategies
5
▸
Modular monolith
Modular monolith
7
Challenges
▸ Strong data consistency requirements
▸ Strict performance requirements
▸ Complex business transactions
Solution
▸ Single process deployment unit
▸ Independent modules with clear responsibilities and
well-defined interfaces/contracts
▸ Each module access only its tables
Implementation options
8
Diagram credits @axelfontaine
Modular monolith
9
Benefits
▸ Simple transaction semantics with local transactions
▸ ACID properties
Drawbacks
▸ Shared runtime hinders independent deployment,
scalability, and failure isolation
▸ Shared database can lead to coupling among modules
Two-phase
commit
Two-phase commit
11
Challenges
▸ Strong data consistency requirements
▸ Heterogeneous data sources
▸ Integrating with a third-party or legacy system
▸ Exactly-once message processing
Solution
▸ 2PC protocol and X/Open XA specification
▸ JTA and WS AtomicTransaction implementations
Implementation options
12
Distributed transaction managers
▸ Narayana, JOTM, BTM, Atomikos, MSDTC
Datasources
▸ PostgreSQL, MySQL, Db2, Oracle, SQL Server
▸ ActiveMQ, HornetQ, MSMQ, IBM MQ, Solace
▸ Infinispan, Hazelcast
Non 2PC/XA distributed transactions
▸ eBay’s GRIT protocol
Two-phase commit
13
Benefits
▸ An out-of-the-box, standard-based solution
▸ Implemented by many traditional datasources
▸ ACID properties
Drawbacks
▸ A blocking protocol with database locks and
performance penalty
▸ All participating services must be available
▸ Manual recovery from controller crashes
Dual write strategies
14
Orchestration
based Saga
Challenges
▸ Business process spanning several services
▸ Business functions lasting for hours or days
▸ A single location for management and monitoring of
distributed transactions
Solution
▸ Implement each business transaction that spans multiple
services as a sequence of local transactions
Saga
16
Saga implementation options
17
Coordination approaches
▸ Orchestration - a controller tells the participants what local
transactions to execute
▸ Choreography - business transaction coordination logic is
spread among all participants
Communication mechanisms
▸ Synchronous, for example HTTP, gRPC
▸ Asynchronous, for example Apache ActiveMQ, Apache Kafka
Orchestration
Choreography
Orchestration based Saga
18
Benefits
▸ Doesn’t require all participants to be available at the same
time, nor to have knowledge about each other
▸ Single place to define and monitor the transaction flow
Drawbacks
▸ Complex programing model, requires coordination,
compensation logic, and idempotency implementations
▸ Lacks Isolation from AC*D properties which can cause dirty
reads, lost updates, non-repeatable reads
Choreography
Choreography
20
Challenges
▸ Business process spanning several services
▸ Business functions lasting for hours or days
▸ Highly scalable and available system
Solution
▸ Implement each business transaction that spans multiple
services as a sequence of local transactions with
distributing decision making in each service
Choreography
21
Benefits
▸ Doesn't require a transaction coordinator service
▸ Better performance compared to orchestration approach
due to smaller number of interactions
Drawbacks
▸ No single place to define and monitor the business
transaction flow
▸ Coupling among participant with point to point interactions
▸ Lacks Isolation from AC*D properties
Implementation options
22
Publish, then local-commit
Local-commit, then publish
Event sourcing Outbox pattern
Two-phase commit
Outbox Pattern
23
Offers an approach for services to update their data store and
notify other services in a reliable and eventually consistent
manner.
Benefits
▸ Addresses the dual-write problem
▸ Offers “read your own writes" semantics
Drawbacks
▸ Requires specialized tools, such as Debezium
Parallel pipeline
Parallel pipelines
25
Challenges
▸ Avoid dual writes to a local database and a messaging
system
Solution
▸ Publish a message to other services and yourself in the
same messaging system
Listen to Yourself
26
Benefits
▸ Simple, scalable architecture with parallel processing
capabilities
Drawbacks
▸ Requires temporal dismantling, not commonly applicable
▸ Hard to reason about the global system state
▸ Lacks “read your own writes" semantics
Summary
Dual write strategies
28
Dual write strategies for microservices
29
Modular
Monolith
Two-phase
Commit
Orchestration Choreography
Parallel
Pipeline
Service runtime Single process Single/Multiple Multiple Multiple Multiple
Datasources Single
Heterogeneous
(requires XA)
Heterogeneous Heterogeneous Heterogeneous
Point of control Centralized Centralized Centralized Distributed Distributed
Steps/Flow
execution
At once
At once
(for happy paths),
highly coupled
Sequential,
temporal
decoupling
Sequential,
temporal
decoupling
Parallel,
temporal
decoupling
Properties
ACID,
blocking,
synchronous
ACID,
blocking,
synchronous
ACD,
non-blocking,
(a)synchronous,
ACD,
non-blocking,
asynchronous,
ACD,
non-blocking,
asynchronous,
Examples
Local
transactions
XA, JTA, WS-AT
Saga/Outbox,
Debezium, Kafka
Saga/Outbox,
Debezium, Kafka
Listen to yourself
pattern
30
Red Hat OpenShift Streams
for Apache Kafka
a fully managed Apache Kafka service by Red Hat
http://red.ht/TryKafka
Try Apache Kafka in seconds
Dual write strategies for microservices

More Related Content

What's hot

What's hot (20)

Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Introduction To Microservices
Introduction To MicroservicesIntroduction To Microservices
Introduction To Microservices
 
Microservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, KanbanMicroservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, Kanban
 
Grokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKI
 
Kubernetes Architecture
 Kubernetes Architecture Kubernetes Architecture
Kubernetes Architecture
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
 
Micro services Architecture
Micro services ArchitectureMicro services Architecture
Micro services Architecture
 
QConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
QConPlus 2021: Minimizing Design Time Coupling in a Microservice ArchitectureQConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
QConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
 
Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018
 
CQRS and event sourcing
CQRS and event sourcingCQRS and event sourcing
CQRS and event sourcing
 
Kafka Connect - debezium
Kafka Connect - debeziumKafka Connect - debezium
Kafka Connect - debezium
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native Apps
 
Building Microservices with Apache Kafka
Building Microservices with Apache KafkaBuilding Microservices with Apache Kafka
Building Microservices with Apache Kafka
 
Saturn 2018: Managing data consistency in a microservice architecture using S...
Saturn 2018: Managing data consistency in a microservice architecture using S...Saturn 2018: Managing data consistency in a microservice architecture using S...
Saturn 2018: Managing data consistency in a microservice architecture using S...
 
Microservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesMicroservices Architecture & Testing Strategies
Microservices Architecture & Testing Strategies
 
Designing loosely coupled services
Designing loosely coupled servicesDesigning loosely coupled services
Designing loosely coupled services
 
Application modernization patterns with apache kafka, debezium, and kubernete...
Application modernization patterns with apache kafka, debezium, and kubernete...Application modernization patterns with apache kafka, debezium, and kubernete...
Application modernization patterns with apache kafka, debezium, and kubernete...
 
Building Event-Driven (Micro) Services with Apache Kafka
Building Event-Driven (Micro) Services with Apache KafkaBuilding Event-Driven (Micro) Services with Apache Kafka
Building Event-Driven (Micro) Services with Apache Kafka
 
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
 
Introducing Saga Pattern in Microservices with Spring Statemachine
Introducing Saga Pattern in Microservices with Spring StatemachineIntroducing Saga Pattern in Microservices with Spring Statemachine
Introducing Saga Pattern in Microservices with Spring Statemachine
 

Similar to Dual write strategies for microservices

Similar to Dual write strategies for microservices (20)

Modernization patterns to refactor a legacy application into event driven mic...
Modernization patterns to refactor a legacy application into event driven mic...Modernization patterns to refactor a legacy application into event driven mic...
Modernization patterns to refactor a legacy application into event driven mic...
 
Azure Application Architecture Guide
Azure Application Architecture GuideAzure Application Architecture Guide
Azure Application Architecture Guide
 
JavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsJavaScript for Enterprise Applications
JavaScript for Enterprise Applications
 
Slow things down to make them go faster [FOSDEM 2022]
Slow things down to make them go faster [FOSDEM 2022]Slow things down to make them go faster [FOSDEM 2022]
Slow things down to make them go faster [FOSDEM 2022]
 
API Microservices with Node.js and Docker
API Microservices with Node.js and DockerAPI Microservices with Node.js and Docker
API Microservices with Node.js and Docker
 
Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...
Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...
Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...
 
Redis and Kafka - Advanced Microservices Design Patterns Simplified
Redis and Kafka - Advanced Microservices Design Patterns SimplifiedRedis and Kafka - Advanced Microservices Design Patterns Simplified
Redis and Kafka - Advanced Microservices Design Patterns Simplified
 
Pragmatic Approach to Microservices and Cell-based Architecture
Pragmatic Approach to Microservices and Cell-based Architecture Pragmatic Approach to Microservices and Cell-based Architecture
Pragmatic Approach to Microservices and Cell-based Architecture
 
Multi-Cloud Strategy for Unrestricted Possibilities
Multi-Cloud Strategy for Unrestricted PossibilitiesMulti-Cloud Strategy for Unrestricted Possibilities
Multi-Cloud Strategy for Unrestricted Possibilities
 
Adopting the Cloud
Adopting the CloudAdopting the Cloud
Adopting the Cloud
 
#GeodeSummit - Where Does Geode Fit in Modern System Architectures
#GeodeSummit - Where Does Geode Fit in Modern System Architectures#GeodeSummit - Where Does Geode Fit in Modern System Architectures
#GeodeSummit - Where Does Geode Fit in Modern System Architectures
 
Serverless microservices
Serverless microservicesServerless microservices
Serverless microservices
 
Stateful on Stateless - The Future of Applications in the Cloud
Stateful on Stateless - The Future of Applications in the CloudStateful on Stateless - The Future of Applications in the Cloud
Stateful on Stateless - The Future of Applications in the Cloud
 
Hybrid Cloud Transformation Fast Track.pptx
Hybrid Cloud Transformation Fast Track.pptxHybrid Cloud Transformation Fast Track.pptx
Hybrid Cloud Transformation Fast Track.pptx
 
POV - Practical Containerization
POV - Practical ContainerizationPOV - Practical Containerization
POV - Practical Containerization
 
Overcoming Data Gravity in Multi-Cloud Enterprise Architectures
Overcoming Data Gravity in Multi-Cloud Enterprise ArchitecturesOvercoming Data Gravity in Multi-Cloud Enterprise Architectures
Overcoming Data Gravity in Multi-Cloud Enterprise Architectures
 
Accelerating the Path to Digital with a Cloud Data Strategy
Accelerating the Path to Digital with a Cloud Data StrategyAccelerating the Path to Digital with a Cloud Data Strategy
Accelerating the Path to Digital with a Cloud Data Strategy
 
Microservices for Application Modernisation
Microservices for Application ModernisationMicroservices for Application Modernisation
Microservices for Application Modernisation
 
Caching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session ICaching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session I
 
AME-1934 : Enable Active-Active Messaging Technology to Extend Workload Balan...
AME-1934 : Enable Active-Active Messaging Technology to Extend Workload Balan...AME-1934 : Enable Active-Active Messaging Technology to Extend Workload Balan...
AME-1934 : Enable Active-Active Messaging Technology to Extend Workload Balan...
 

More from Bilgin Ibryam

More from Bilgin Ibryam (11)

Dapr - A 10x Developer Framework for Any Language
Dapr - A 10x Developer Framework for Any LanguageDapr - A 10x Developer Framework for Any Language
Dapr - A 10x Developer Framework for Any Language
 
How to financially survive while growing a small open source project
How to financially survive while growing a small open source projectHow to financially survive while growing a small open source project
How to financially survive while growing a small open source project
 
What next after microservices
What next after microservicesWhat next after microservices
What next after microservices
 
The Evolution of Distributed Systems on Kubernetes
The Evolution of Distributed Systems on KubernetesThe Evolution of Distributed Systems on Kubernetes
The Evolution of Distributed Systems on Kubernetes
 
Enterprise Integration for Ethereum
Enterprise Integration for EthereumEnterprise Integration for Ethereum
Enterprise Integration for Ethereum
 
The Kubernetes Effect
The Kubernetes EffectThe Kubernetes Effect
The Kubernetes Effect
 
Designing Cloud Native Applications with Kubernetes
Designing Cloud Native Applications with KubernetesDesigning Cloud Native Applications with Kubernetes
Designing Cloud Native Applications with Kubernetes
 
Cloud Native Patterns
Cloud Native PatternsCloud Native Patterns
Cloud Native Patterns
 
Cloud Native Java Development Patterns
Cloud Native Java Development PatternsCloud Native Java Development Patterns
Cloud Native Java Development Patterns
 
Cloud Native Camel Design Patterns
Cloud Native Camel Design PatternsCloud Native Camel Design Patterns
Cloud Native Camel Design Patterns
 
Camel Desing Patterns Learned Through Blood, Sweat, and Tears
Camel Desing Patterns Learned Through Blood, Sweat, and TearsCamel Desing Patterns Learned Through Blood, Sweat, and Tears
Camel Desing Patterns Learned Through Blood, Sweat, and Tears
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Dual write strategies for microservices

  • 1. Dual Write Strategies for Microservices Bilgin Ibryam @bibryam Product Manager Red Hat
  • 2. About me 2 ▸ Product Manager at Red Hat ▸ Former Principal Architect ▸ Committer at Apache Camel ▸ Author ・ Camel Design Patterns ・ Kubernetes Patterns ▸ @ bibryam ▸ https://www.ofbizian.com
  • 3. There is a catch 3 Challenges with legacy applications ▸ Frequent deployment is difficult ▸ Obstacles to scaling development ▸ Scaling the application can be difficult Modern application benefits ▸ Greater team autonomy ▸ Reliability, scalability, and other abilities ▸ Reduce time to market
  • 4. The dual-write problem 4 Dual-write challenge behind the scene ▸ Updating more than one resources ▸ Reliable inter-service communication ▸ Coordinating long-running, business transactions ▸ Recovery from failed distributed transaction ▸ Implementing idempotent operations ▸ Scaling with increasing data volume
  • 7. Modular monolith 7 Challenges ▸ Strong data consistency requirements ▸ Strict performance requirements ▸ Complex business transactions Solution ▸ Single process deployment unit ▸ Independent modules with clear responsibilities and well-defined interfaces/contracts ▸ Each module access only its tables
  • 9. Modular monolith 9 Benefits ▸ Simple transaction semantics with local transactions ▸ ACID properties Drawbacks ▸ Shared runtime hinders independent deployment, scalability, and failure isolation ▸ Shared database can lead to coupling among modules
  • 11. Two-phase commit 11 Challenges ▸ Strong data consistency requirements ▸ Heterogeneous data sources ▸ Integrating with a third-party or legacy system ▸ Exactly-once message processing Solution ▸ 2PC protocol and X/Open XA specification ▸ JTA and WS AtomicTransaction implementations
  • 12. Implementation options 12 Distributed transaction managers ▸ Narayana, JOTM, BTM, Atomikos, MSDTC Datasources ▸ PostgreSQL, MySQL, Db2, Oracle, SQL Server ▸ ActiveMQ, HornetQ, MSMQ, IBM MQ, Solace ▸ Infinispan, Hazelcast Non 2PC/XA distributed transactions ▸ eBay’s GRIT protocol
  • 13. Two-phase commit 13 Benefits ▸ An out-of-the-box, standard-based solution ▸ Implemented by many traditional datasources ▸ ACID properties Drawbacks ▸ A blocking protocol with database locks and performance penalty ▸ All participating services must be available ▸ Manual recovery from controller crashes
  • 16. Challenges ▸ Business process spanning several services ▸ Business functions lasting for hours or days ▸ A single location for management and monitoring of distributed transactions Solution ▸ Implement each business transaction that spans multiple services as a sequence of local transactions Saga 16
  • 17. Saga implementation options 17 Coordination approaches ▸ Orchestration - a controller tells the participants what local transactions to execute ▸ Choreography - business transaction coordination logic is spread among all participants Communication mechanisms ▸ Synchronous, for example HTTP, gRPC ▸ Asynchronous, for example Apache ActiveMQ, Apache Kafka Orchestration Choreography
  • 18. Orchestration based Saga 18 Benefits ▸ Doesn’t require all participants to be available at the same time, nor to have knowledge about each other ▸ Single place to define and monitor the transaction flow Drawbacks ▸ Complex programing model, requires coordination, compensation logic, and idempotency implementations ▸ Lacks Isolation from AC*D properties which can cause dirty reads, lost updates, non-repeatable reads
  • 20. Choreography 20 Challenges ▸ Business process spanning several services ▸ Business functions lasting for hours or days ▸ Highly scalable and available system Solution ▸ Implement each business transaction that spans multiple services as a sequence of local transactions with distributing decision making in each service
  • 21. Choreography 21 Benefits ▸ Doesn't require a transaction coordinator service ▸ Better performance compared to orchestration approach due to smaller number of interactions Drawbacks ▸ No single place to define and monitor the business transaction flow ▸ Coupling among participant with point to point interactions ▸ Lacks Isolation from AC*D properties
  • 22. Implementation options 22 Publish, then local-commit Local-commit, then publish Event sourcing Outbox pattern Two-phase commit
  • 23. Outbox Pattern 23 Offers an approach for services to update their data store and notify other services in a reliable and eventually consistent manner. Benefits ▸ Addresses the dual-write problem ▸ Offers “read your own writes" semantics Drawbacks ▸ Requires specialized tools, such as Debezium
  • 25. Parallel pipelines 25 Challenges ▸ Avoid dual writes to a local database and a messaging system Solution ▸ Publish a message to other services and yourself in the same messaging system
  • 26. Listen to Yourself 26 Benefits ▸ Simple, scalable architecture with parallel processing capabilities Drawbacks ▸ Requires temporal dismantling, not commonly applicable ▸ Hard to reason about the global system state ▸ Lacks “read your own writes" semantics
  • 29. Dual write strategies for microservices 29 Modular Monolith Two-phase Commit Orchestration Choreography Parallel Pipeline Service runtime Single process Single/Multiple Multiple Multiple Multiple Datasources Single Heterogeneous (requires XA) Heterogeneous Heterogeneous Heterogeneous Point of control Centralized Centralized Centralized Distributed Distributed Steps/Flow execution At once At once (for happy paths), highly coupled Sequential, temporal decoupling Sequential, temporal decoupling Parallel, temporal decoupling Properties ACID, blocking, synchronous ACID, blocking, synchronous ACD, non-blocking, (a)synchronous, ACD, non-blocking, asynchronous, ACD, non-blocking, asynchronous, Examples Local transactions XA, JTA, WS-AT Saga/Outbox, Debezium, Kafka Saga/Outbox, Debezium, Kafka Listen to yourself pattern
  • 30. 30 Red Hat OpenShift Streams for Apache Kafka a fully managed Apache Kafka service by Red Hat http://red.ht/TryKafka Try Apache Kafka in seconds