SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
3.
Order
Order
Line Item
Customer
Customer
Address
orderId
customerId
chargeId
…
customerId
…
productId
price
…
Charge
Charge
Order
chargeId
amount
paymentProvider
transactionId
…
Aggregate
Entity
Value Object
Reference by identity
@berndruecker
4.
Order
Order
Line Item
orderId
customerId
chargeId
…
productId
price
… Order
Charge
Charge
chargeId
amount
paymentProvider
transactionId
… Create
Charge
Mark
order as
paid
All or
nothing
+
@berndruecker
5.
A
C
I
D
Atomicity
Consistency
Isolation
Durability
@berndruecker
6.
Aggregates = Consistency Boundaries
Order
Order
Line Item
orderId
customerId
chargeId
…
productId
price
… Order
Charge
Charge
chargeId
amount
paymentProvider
transactionId
…
You can do ACID
within here
Or here
But not a joined
ACID transaction!
@berndruecker
7.
Aggregates = Consistency Boundaries
Order
Order
Line Item
orderId
customerId
chargeId
…
productId
price
… Order
Charge
Charge
chargeId
amount
paymentProvider
transactionId
…
Own DB / autonomous technology decisions
API-driven
Scalability
…
@berndruecker
8.
Aggregates = Consistency Boundaries
Order
Order
Line Item
orderId
customerId
chargeId
…
productId
price
… Order
Charge
Charge
chargeId
amount
paymentProvider
transactionId
…
Own DB / autonomous technology decisions
API-driven
Scalability
…
@berndruecker
9.
Boundaries need to be designed carefully
Charge
chargeId
amount
paymentProvider
transactionId
…
Order
Order
Line Item
orderId
customerId
chargeId
…
productId
price
…Order
@berndruecker
10.
But no implicit constraints!
Order
Order
Line Item
orderId
customerId
chargeId
…
productId
price
… Order
Charge
Charge
chargeId
amount
paymentProvider
transactionId
…
Joined DB
transaciton
@berndruecker
11.
There is two-phase commit (XA)!!
TX
Coordinator
Resource
Managers
Prepare
Phase
Commit
Phase
@berndruecker
12.
Pat Helland
“
Distributed Systems Guru
Worked at Amazon,
Microsoft & Salesforce
@berndruecker
13.
Pat Helland
Grown-Ups Don’t Use
Distributed Transactions
“
Distributed Systems Guru
Worked at Amazon,
Microsoft & Salesforce
@berndruecker
14.
Starbucks does not use two phase commit
https://www.enterpriseintegrationpatterns.com/ramblings/18_starbucks.html
Photo by John Ingle
@berndruecker
15.
Eric Brewer
Atomicity
Consistency
Isolation
Durability
http://pld.cs.luc.edu/courses/353/spr11/notes/brewer_keynote.pdf @berndruecker
16.
That means
Do A
Do B
Temporarily
inconsistent
Eventually
consistent
again
t
Consistent
Local
ACID
Local
ACID
1 aggregate
1 (micro-)service
1 program
1 resource
Violates „I“
of ACID
@berndruecker
17.
Youmightknowthisfrom:
Do A
Do B
Temporarily
inconsistent
Eventually
consistent
again
t
Consistent
Photo by Gerhard51, available under Creative Commons CC0 1.0 license.
@berndruecker
18.
„Building on Quicksand“ Paper
A
C
I
D
2.0Pat Helland
@berndruecker
19.
Associative
Commutative
Idempotent
Distributed
2.0
(a + b) + c = a + (b + c)
a + b = b + a
f(x) = f( f(x) )
„Building on Quicksand“ Paper
Pat Helland
@berndruecker
47.
Compensation – the classical example
Saga
book
hotel
book
car
book
flight
cancel
hotel
cancel
car
1. 2. 3.
5.6.
In case of failure
trigger compensations
book
trip
49.
Event-driven choreography
Hotel
Flight
Car
Trip
Trip
booked
Flight
booked
Trip
requested
Hotel
booked
Car
booked
Request
trip
@berndruecker
50.
Event-driven choreography
Hotel
Flight
Car
Trip
Trip
failed
Trip
requested
Hotel
booked
Car
booked
Request
trip
Flight
failed
Car
canceled
Hotel
canceled
Perform undo
(cancel car booking)
Perform undo
(cancel hotel)
@berndruecker
51.
The danger is that it's very easy to make
nicely decoupled systems with event
notification, without realizing that you're
losing sight of that larger-scale flow, and
thus set yourself up for trouble in future
years.
https://martinfowler.com/articles/201701-event-driven.html
@berndruecker
52.
The danger is that it's very easy to make
nicely decoupled systems with event
notification, without realizing that you're
losing sight of that larger-scale flow, and
thus set yourself up for trouble in future
years.
https://martinfowler.com/articles/201701-event-driven.html
@berndruecker
53.
The danger is that it's very easy to make
nicely decoupled systems with event
notification, without realizing that you're
losing sight of that larger-scale flow, and
thus set yourself up for trouble in future
years.
https://martinfowler.com/articles/201701-event-driven.html
@berndruecker
54.
If your transaction involves 2 to 4 steps,
choreography might be a very good fit.
However, this approach can rapidly become confusing
if you keep adding extra steps in your transaction
as it is difficult to track which services listen to
which events. Moreover, it also might add a cyclic
dependency between services as they have to
subscribe to one another’s events.
Denis Rosa
Couchbase
https://blog.couchbase.com/saga-pattern-implement-business-transactions-using-microservices-part/
@berndruecker
55.
Implementing changes in the process
Hotel
Flight
Car
Trip
Trip
failed
Trip
requested
Hotel
booked
Car
booked
Request
trip
Flight
failed
Car
canceled
Hotel
canceled
We have a new basic agreement
with the car rental agency and
can cancel for free within 1 hour
– do that first!
@berndruecker
56.
Implementing changes in the process
Hotel
Flight
Car
Trip
Trip
failed
Trip
requested
Hotel
booked
Car
booked
Request
trip
Flight
failed
Car
canceled
Hotel
canceled
You have to adjust all services and redeploy at the same time!
We have a new basic agreement
with the car rental agency and
can cancel for free within 1 hour
– do that first!
@berndruecker
57.
What we wanted
Photo by Lijian Zhang, available under Creative Commons SA 2.0 License and Pedobear19 / CC BY-SA 4.0
@berndruecker
58.
Orchestration
Hotel
Flight
Car
Trip
Trip
booked
Request
trip
Book
hotel
Hotel
booked
Car
booked
Flight
booked
Book
car
Book
flight
@berndruecker
59.
Orchestration
Hotel
Flight
Car
Trip
Trip
booked
Request
trip
Book
hotel
Hotel
booked
Car
booked
Flight
booked
Book
car
Book
flight
We have a new basic agreement
with the car rental agency and
can cancel for free within 1 hour
– do that first!
You have to adjust one service and redeploy only this one!
@berndruecker
72.
Fancy a DSL? Just do it!
https://github.com/berndruecker/flowing-trip-booking-saga
The visual get
auto-generated…
@berndruecker
73.
Thoughts on the state machine | workflow engine market
@berndruecker
74.
Thoughts on the state machine | workflow engine market
OSS Workflow or
Orchestration Engines
Stack Vendors,
Pure Play BPMS
Low Code Platforms
Homegrown frameworks
to scratch an itch
Integration Frameworks
Cloud Offerings
Uber, Netflix, AirBnb, ING, … AWS Step Functions,
Azure Durable Functions, …
Camunda, Zeebe, jBPM,
Activiti, Mistral, …
PEGA, IBM, SAG, …
Apache Airflow,
Spring Data Flow, …
Apache Camel,
Balerina, …
Data
Pipelines
@berndruecker
75.
Does it support stateful operations?
Does it support the necessary flow logic?
Does it support BizDevOps?
Does it scale?
@berndruecker
76.
My personal pro-tip for a shortlist ;-)
OSS Workflow or
Orchestration Engines
Stack Vendors,
Pure Play BPMS
Low Code Platforms
Homegrown frameworks
to scratch an itch
Integration Frameworks
Cloud Offerings
Data
Pipelines
Camunda & Zeebe
@berndruecker
77.
Recap
• Aggregates = Consistency boundaries
• Grown ups don‘t use distributed transactions
but eventual consistency
• Idempotency is super important
• Some consistency challenges require state
• Stateful retry & cleanup
• Saga / Compensation
@berndruecker