SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

우아한 모노리스
우아한 모노리스우아한 모노리스
우아한 모노리스Arawn Park
 
카프카, 산전수전 노하우
카프카, 산전수전 노하우카프카, 산전수전 노하우
카프카, 산전수전 노하우if kakao
 
ksqlDB로 실시간 데이터 변환 및 스트림 처리
ksqlDB로 실시간 데이터 변환 및 스트림 처리ksqlDB로 실시간 데이터 변환 및 스트림 처리
ksqlDB로 실시간 데이터 변환 및 스트림 처리confluent
 
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
Kafka Tutorial - Introduction to Apache Kafka (Part 1)Kafka Tutorial - Introduction to Apache Kafka (Part 1)
Kafka Tutorial - Introduction to Apache Kafka (Part 1)Jean-Paul Azar
 
Grafana Mimir and VictoriaMetrics_ Performance Tests.pptx
Grafana Mimir and VictoriaMetrics_ Performance Tests.pptxGrafana Mimir and VictoriaMetrics_ Performance Tests.pptx
Grafana Mimir and VictoriaMetrics_ Performance Tests.pptxRomanKhavronenko
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.Taras Matyashovsky
 
Kafka Quotas Talk at LinkedIn
Kafka Quotas Talk at LinkedInKafka Quotas Talk at LinkedIn
Kafka Quotas Talk at LinkedInAditya Auradkar
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)Jean-François Gagné
 
Git interview questions | Edureka
Git interview questions | EdurekaGit interview questions | Edureka
Git interview questions | EdurekaEdureka!
 
From Mainframe to Microservice: An Introduction to Distributed Systems
From Mainframe to Microservice: An Introduction to Distributed SystemsFrom Mainframe to Microservice: An Introduction to Distributed Systems
From Mainframe to Microservice: An Introduction to Distributed SystemsTyler Treat
 
Stream processing using Kafka
Stream processing using KafkaStream processing using Kafka
Stream processing using KafkaKnoldus Inc.
 
Microservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and SagaMicroservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and SagaAraf Karsh Hamid
 
Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)WSO2
 
Zero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with KubernetesZero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with KubernetesWojciech Barczyński
 
Spring Boot+Kafka: the New Enterprise Platform
Spring Boot+Kafka: the New Enterprise PlatformSpring Boot+Kafka: the New Enterprise Platform
Spring Boot+Kafka: the New Enterprise PlatformVMware Tanzu
 
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...Chris Richardson
 

Tendances (20)

우아한 모노리스
우아한 모노리스우아한 모노리스
우아한 모노리스
 
카프카, 산전수전 노하우
카프카, 산전수전 노하우카프카, 산전수전 노하우
카프카, 산전수전 노하우
 
ksqlDB로 실시간 데이터 변환 및 스트림 처리
ksqlDB로 실시간 데이터 변환 및 스트림 처리ksqlDB로 실시간 데이터 변환 및 스트림 처리
ksqlDB로 실시간 데이터 변환 및 스트림 처리
 
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
Kafka Tutorial - Introduction to Apache Kafka (Part 1)Kafka Tutorial - Introduction to Apache Kafka (Part 1)
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
 
Grafana Mimir and VictoriaMetrics_ Performance Tests.pptx
Grafana Mimir and VictoriaMetrics_ Performance Tests.pptxGrafana Mimir and VictoriaMetrics_ Performance Tests.pptx
Grafana Mimir and VictoriaMetrics_ Performance Tests.pptx
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.
 
Kafka Quotas Talk at LinkedIn
Kafka Quotas Talk at LinkedInKafka Quotas Talk at LinkedIn
Kafka Quotas Talk at LinkedIn
 
Why Microservices
Why MicroservicesWhy Microservices
Why Microservices
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
 
Git interview questions | Edureka
Git interview questions | EdurekaGit interview questions | Edureka
Git interview questions | Edureka
 
From Mainframe to Microservice: An Introduction to Distributed Systems
From Mainframe to Microservice: An Introduction to Distributed SystemsFrom Mainframe to Microservice: An Introduction to Distributed Systems
From Mainframe to Microservice: An Introduction to Distributed Systems
 
Stream processing using Kafka
Stream processing using KafkaStream processing using Kafka
Stream processing using Kafka
 
Microservices Decomposition Patterns
Microservices Decomposition PatternsMicroservices Decomposition Patterns
Microservices Decomposition Patterns
 
Microservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and SagaMicroservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and Saga
 
Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)
 
Zero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with KubernetesZero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with Kubernetes
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Spring Boot+Kafka: the New Enterprise Platform
Spring Boot+Kafka: the New Enterprise PlatformSpring Boot+Kafka: the New Enterprise Platform
Spring Boot+Kafka: the New Enterprise Platform
 
Redis
RedisRedis
Redis
 
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...
 

Similaire à Dual write strategies for microservices

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...Bilgin Ibryam
 
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...Bilgin Ibryam
 
Azure Application Architecture Guide
Azure Application Architecture GuideAzure Application Architecture Guide
Azure Application Architecture GuideMasashi Narumoto
 
JavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsJavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsPiyush Katariya
 
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]Jimmy Angelakos
 
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 DockerApigee | Google Cloud
 
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 SimplifiedAllen Terleto
 
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...HostedbyConfluent
 
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 Andrew Blades
 
Multi-Cloud Strategy for Unrestricted Possibilities
Multi-Cloud Strategy for Unrestricted PossibilitiesMulti-Cloud Strategy for Unrestricted Possibilities
Multi-Cloud Strategy for Unrestricted PossibilitiesHarsh V Sehgal
 
#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 ArchitecturesPivotalOpenSourceHub
 
Serverless microservices
Serverless microservicesServerless microservices
Serverless microservicesLalit Kale
 
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 CloudMarkus Eisele
 
Hybrid Cloud Transformation Fast Track.pptx
Hybrid Cloud Transformation Fast Track.pptxHybrid Cloud Transformation Fast Track.pptx
Hybrid Cloud Transformation Fast Track.pptxzhunli4
 
POV - Practical Containerization
POV - Practical ContainerizationPOV - Practical Containerization
POV - Practical ContainerizationRobert Greiner
 
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 ArchitecturesVMware Tanzu
 
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 StrategyMongoDB
 
Microservices for Application Modernisation
Microservices for Application ModernisationMicroservices for Application Modernisation
Microservices for Application ModernisationAjay Kumar Uppal
 
Caching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session ICaching for Microservices Architectures: Session I
Caching for Microservices Architectures: Session IVMware Tanzu
 

Similaire à Dual write strategies for microservices (20)

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...
 
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 - 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
 
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...
 
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
 

Plus de Bilgin Ibryam

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 LanguageBilgin Ibryam
 
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 projectBilgin Ibryam
 
What next after microservices
What next after microservicesWhat next after microservices
What next after microservicesBilgin Ibryam
 
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 KubernetesBilgin Ibryam
 
Enterprise Integration for Ethereum
Enterprise Integration for EthereumEnterprise Integration for Ethereum
Enterprise Integration for EthereumBilgin Ibryam
 
The Kubernetes Effect
The Kubernetes EffectThe Kubernetes Effect
The Kubernetes EffectBilgin Ibryam
 
Designing Cloud Native Applications with Kubernetes
Designing Cloud Native Applications with KubernetesDesigning Cloud Native Applications with Kubernetes
Designing Cloud Native Applications with KubernetesBilgin Ibryam
 
Cloud Native Patterns
Cloud Native PatternsCloud Native Patterns
Cloud Native PatternsBilgin Ibryam
 
Cloud Native Java Development Patterns
Cloud Native Java Development PatternsCloud Native Java Development Patterns
Cloud Native Java Development PatternsBilgin Ibryam
 
Cloud Native Camel Design Patterns
Cloud Native Camel Design PatternsCloud Native Camel Design Patterns
Cloud Native Camel Design PatternsBilgin Ibryam
 
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 TearsBilgin Ibryam
 

Plus de 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
 

Dernier

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 

Dernier (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 

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