SlideShare a Scribd company logo
© Fraunhofer IESE
EVENTUAL CONSISTENCY
Du musst keine Angst haben…
Susanne Braun
18.11.2021
Java User Group Darmstadt
Oder doch?
© Fraunhofer IESE
2
Pat Helland
Database & Distributed Systems Guru
Architect of multiple transaction &
database systems (e.g. DynamoDB)
Worked at Microsoft, Amazon, SalesForce, …
“There is an interesting connection
between
fault tolerance, offlineable systems,
and the need for
application-based eventual
consistency.”
application-based eventual
consistency
fault tolerance, offlineable systems
Conference on Innovative Data Systems Research, 2009
© Fraunhofer IESE
3
“Correlating” Quality Attributes
Fault Tolerance Resilience
Loose Coupling
Availability
Scalability
Offline
Capability
Network
Partition
Tolerance
Low Latency
Responsiveness
© Fraunhofer IESE
4
Eric Brewer
Distributed Systems Researcher
Coined the CAP theorem, Contributed to
Spanner
Prof. emeritus University of California, Berkeley,
works now for Google
“But we forfeit C and I of ACID for
availability, graceful degradation and
performance.”
ACM Symposium on Principles of Distributed Computing, 2000
© Fraunhofer IESE
5
ACID vs. BASE
ACID BASE
Strong Consistency
(in the sense of one-copy-consistency)
Isolation
(in the sense of one-copy-serializability)
Pessimistic Synchronization
(global locks, synchronous update propagation)
Global Commits
(2PC, majority consensus, …)
Atomicity
Consistency
Isolation
Durability
Eventual Consistency
(stale data & approximate answers)
Availability
(top priority)
Optimistic Synchronization
(no locks, asynchronous update propagation)
Independent Local Commits
(conflict resolution, reconciliation, …)
Atomicity
Consistency
Isolation
Durability ?
Database is in a consistent state &
all invariants are being met!
This is about Concurrency Control!
This is about Convergence!
© Fraunhofer IESE
6
Consistency vs. Isolation
“Consistency tries to mask the distributed nature of the system”
“Isolation tries to mask the effects of concurrent execution”
Make it appear
as one system!
Make it appear I am the
only user of the system!
© Fraunhofer IESE
7
Douglas Terry
Distributed Systems Researcher
Coined the term Eventual Consistency in the
90ties
Former Prof. University of California, Berkeley,
worked for Microsoft, Samsung, AWS
“A system providing eventual
consistency guarantees that replicas
would eventually converge to a
mutually consistent state, i.e., to
identical contents, if update activity
ceased.”
Int. Conference on Parallel and Distributed Information Systems, 1994
© Fraunhofer IESE
8
Douglas Terry
Distributed Systems Researcher
Coined the term Eventual Consistency in the
90ties
Former Prof. University of California, Berkeley,
worked for Microsoft, Samsung, AWS
“A system providing eventual
consistency guarantees that replicas
would eventually converge to a
mutually consistent state, i.e., to
identical contents, if update activity
ceased.”
Int. Conference on Parallel and Distributed Information Systems, 1994
Pragmatic Definition
A system provides eventual consistency if:
(1)each update operation is eventually received by each
replica
(2)non-commutative update operations are performed
in the same order at each replica
(3)the outcome of a sequence of update operations is
the same at each replica (determinism)
Replicated Data Management for Mobile Computing, 2008
© Fraunhofer IESE
9
Eventual Consistency
Remember:
The only guarantee you get:
convergence to identical state
Outdated Data
Conflicts
Potential Concurrency Anomalies
Events / Operations coming out of order
Application needs to handle:
Huge source of human error!
© Fraunhofer IESE
10
Eventual Consistency
Remember:
You do not get any isolation guarantees like ‘Repeatable Read’
Hard to test
Issues emerge randomly in production
… are hard to reproduce
… are hard to debug
Application needs to handle concurrency control:
Huge source of human error!
© Fraunhofer IESE
11
Consistency in Non-Transactional Distributed Storage Systems
Source: ACM Computing Surveys, Vol. 49, No. 1, Article 19, 2016
© Fraunhofer IESE
12
Pat Helland
Database & Distributed Systems Guru
Architect of multiple transaction &
database systems (e.g. DynamoDB)
Worked at Microsoft, Amazon, SalesForce, …
“… it is time for us to move past the
examination of eventual consistency
in terms of updates and storage
systems. The real action comes when
examining application-based
operation semantics.”
in terms of Reads and Writes
application-based
operation semantics
in terms of updates and storage
Conference on Innovative Data Systems Research, 2009
eventual consistency
systems
© Fraunhofer IESE
14
DDD Layered Architecture
Infrastructure
Layer
Domain
Layer
Application
Layer
DB
SELECT Statement
DB
UPDATE Statement
Application Service
Transaction Method
Aggregate Repository
Query Method (findBy…)
Aggregate
Domain Logic Method
DB
BOT
DB
EOT
DIP
DIP
Low
level
Read
/
Write
Operations
Business
Operations
Processes,
workflows
Application Code
Domain Model
Eventual Consistency
Goal
Business
Semantics
© Fraunhofer IESE
15
Recap Concurrency Control in Relational DBs
n A schedule of concurrent transactions is conflict-serializable iff the conflict graph is acyclic and
compatible with the execution order of the conflicting operations
Time
R(a) W(a) R(a) W(a) R(b) W(b) R(b) W(b)
Transactions T1, T2:
T1 T2
Conflict graph:
Conflict graph is cyclic
⇢ No conflict serializability
⇢ Schedule would be rejected
© Fraunhofer IESE
17
Business Semantics - Banking
t
R(a) W(a) R(a) W(a) R(b) W(b) R(b) W(b)
Withdraw(a)
T1
Deposit(b)
Withdraw(a) Deposit(b)
T2
© Fraunhofer IESE
18
Multilevel Transactions
(Weikum et al. 1992)
n If at each level the conflict serialization graph is acyclic then the multilevel schedule is in total
multilevel serializable
n Exploit semantics of operations in level-specific conflict relations that reflect the
commutativity / compatibility of operations
n Transactions are decomposed into operations and the operations again into sub-operations on
multiple levels
n Transactions, Business operations, Low-level read and write operations
n At each level a conflict relationship is defined
n read-write conflicts and write-write conflicts on the same data item conflict at the lowest level
n Non-commutative operations are conflicting on the level of business operations
In practice comparable to serializability!
Goal: Increase number of operations that can run concurrently!
© Fraunhofer IESE
21
Multilevel Transactions Example
(Weikum et al. 1992)
t
R(a) W(a) R(a) W(a) R(b) W(b) R(b) W(b)
Withdraw(a)
T1
Deposit(b)
Withdraw(a) Deposit(b)
T2
Conflict graph at level
of domain operations:
Conflict graph at
level of transactions: ⌀
1
2
3
Low level Read
/ Write
Operations
Domain
Operations
Transactions
Withdraw(a) Withdraw(a)
Deposit(b) Deposit(b)
Conflict graph is acyclic at each level!
2 1
3 2
© Fraunhofer IESE
23
DDD Layered Architecture
Infrastructure
Layer
Domain
Layer
Application
Layer
DB
SELECT Statement
DB
UPDATE Statement
Application Service
Transaction Method
Aggregate Repository
Query Method (findBy…)
Aggregate
Domain Logic Method
DB
BOT
DB
EOT
DIP
DIP
Low
level
Read
/
Write
Operations
Business
Operations
Processes,
workflows
Application Code
Domain Model
Eventual Consistency
Goal
Business
Semantics
© Fraunhofer IESE
24
Domain
Operation Design
© Fraunhofer IESE
25
Pat Helland
Database & Distributed Systems Guru
Architect of multiple transaction &
database systems (e.g. DynamoDB)
Worked at Microsoft, Amazon, SalesForce, …
Conference on Innovative Data Systems Research, 2009
A
C
I
D
2.0
Associative
Commutative
Idempotent
Distributed
(ab)c = a(bc)
ab = ba
aa = a
Operations
executed out
of order…
© Fraunhofer IESE
26
B
e
s
t
P
r
a
c
t
i
c
e
Popular Examples in Scientific Publications
Commutative Operations
o.domainOperation1(..)
o.domainOperation2(..)
=
o.domainOperation2(..)
o.domainOperaton1(..)
‘o’ is some
Aggregate / Entity / Domain Service
Counters - Integer Addition
Sets – Insert
Banking – Withdraw
Banking – Deposit
© Fraunhofer IESE
29
Annette Bieniusa
CRDT Guru
Co-Creator of AntidoteDB
Worked at INRIA with Marc
Shapiro, TU Kaiserslautern
© Fraunhofer IESE
30
CRDTs are grounded in algebraic
theories of monotonic semilattices
Conflict-Free Replicated Data Types (CRDTs)
CRDTs ship with
commutative merge operations
designed to be a
least upper bound (LUB)
of the conflicting versions.
Intuitive Example: Amazon’s Shopping Card*
Consider LUB as union of different object
states produced at different replicas
Shopping Card
- Soap
- Lotion
Shopping Card
- Lotion
- Brush
Merge
Shopping Card
- Soap
- Lotion
- Brush
Deleted items
might reappear
* Werner Vogels, Communications of the ACM, Volume 52, Issue 1, 2009
© Fraunhofer IESE
32
B
e
s
t
P
r
a
c
t
i
c
e
“Distributed” Operations
Concurrent operations can be executed in a
different order on different replicas.
Example: Concurrent operations
Domain Operations need the ability to
produce intended updates if executed on
different states on different replicas! Replica 1
Replica 2
Operation
Operation Operation
Operation
Operation
© Fraunhofer IESE
33
Collaborative Text Editing
Replica 1
Replica 2
insert(6, ‘r’)
insert(1, ‘e’) insert(2, ‘l’) insert(6, ‘r’)
“Hlo Wold”
“Hlo World”
“Helo Wold” “Hello Wold” “Hello rWold”
© Fraunhofer IESE
37
Domain Data
Design
© Fraunhofer IESE
38
Pat Helland
Database & Distributed Systems Guru
Architect of multiple transaction &
database systems (e.g. DynamoDB)
Worked at Microsoft, Amazon, SalesForce, …
“Immutability Changes Everything”
ACM Queue, Volume 13, Issue 9, 2016
© Fraunhofer IESE
40
C
l
a
s
s
i
f
i
c
a
t
i
o
n
1st Level Classification of Replicated Aggregates
Mutable ?
Observed
Aggregates*
No
Concurrent In-Place Updates ?
Yes
No
Derived
Aggregates*
Multiple Updaters ?
Yes
Dedicated
Aggregates
Nontrivial
Aggregates
Yes
No
* “Append-Only Computing” – Helland 2015
Observed Aggregates:
• Time series data (machine
sensor data, market data, …)
• Domain events
Derived Aggregates:
• Machine generated data
(recommendations, …)
• Timeline or newsfeed data
Dedicated Aggregates:
• User generated data (reviews,
social media posts, ...)
• Dedicated master data (user
profiles, account settings)
E x a m p l e s
© Fraunhofer IESE
42
C
l
a
s
s
i
f
i
c
a
t
i
o
n
2nd Level Classification of Nontrivial Aggregates
Activity Aggregates
Collaboration Result
Aggregates
Reference Aggregates
Dedicated Aggregates
Derived Aggregates
Observed Aggregates
Update Frequency in
Peak Times
Update Simultaneity in
Peak Times
Concurrency Anomaly
Probability
low improbable low
-
Nontrivial
Aggregates
Reference Aggregates Examples:
• Master data (CRM data, resources, products, …)
• Values (Valid currencies, product types, gender, …)
• Meta data (Tags, descrtiptive data of raw data, ..)
© Fraunhofer IESE
43
C
l
a
s
s
i
f
i
c
a
t
i
o
n
2nd Level Classification of Nontrivial Aggregates
Activity Aggregates
Collaboration Result
Aggregates
Reference Aggregates
Dedicated Aggregates
Derived Aggregates
Observed Aggregates
Update Frequency in
Peak Times
Update Simultaneity in
Peak Times
Concurrency Anomaly
Probability
low
high
improbable
probable
low
high
-
Nontrivial
Aggregates
Reference Aggregates Examples:
• Master data (CRM data, resources, products, …)
• Values (Valid currencies, product types, gender, …)
• Meta data (Tags, descrtiptive data of raw data, ..)
Activity Aggregates Examples:
• State data of workflows, business processes, …
• Coordination data of joint activities (agricultural
field operation, meeting, …)
• Task management data, Kanban board data, …
© Fraunhofer IESE
44
C
l
a
s
s
i
f
i
c
a
t
i
o
n
2nd Level Classification of Nontrivial Aggregates
Activity Aggregates
Collaboration Result
Aggregates
Reference Aggregates
Dedicated Aggregates
Derived Aggregates
Observed Aggregates
Update Frequency in
Peak Times
Update Simultaneity in
Peak Times
Concurrency Anomaly
Probability
low
high
very high
improbable
probable
highly probable
low
high
very high
-
Nontrivial
Aggregates
Reference Aggregates Examples:
• Master data (CRM data, resources, products, …)
• Values (Valid currencies, product types, gender, …)
• Meta data (Tags, descrtiptive data of raw data, ..)
Activity Aggregates Examples:
• State data of workflows, business processes, …
• Coordination data of joint activities (agricultural
field operation, meeting, …)
• Task management data, Kanban board data, …
Collaboration Result Aggregates Examples:
• Result data of collaborative knowledge work (CAD
model, crop rotation plan, whiteboard diagram, …)
• Text data as result of collaborative authorship
(manuals, scientific papers, meeting protocols, …)
© Fraunhofer IESE
45
B
e
s
t
P
r
a
c
t
i
c
e
Concurrency Anomalies Impact Assessment
Concurrency Anomaly
Probability
Fixing Costs of
Data Corruption
low
high
very high
very high
high
very high
moderate
very high
moderate
Reference Aggregates
Activity Aggregates
Collaboration Result
Aggregates
Dedicated Aggregates
Derived Aggregates
Observed Aggregates
low
Consequences of
Data Corruption
critical
major
critical
minor
depends
critical
Nontrivial
Aggregates
“Technical Immutability Border”
Trivial
Aggregates
A Classification of Replicated Data for the Design of Eventually Consistent Domain Models,
S. Braun, S. Dessloch, ICSA 2020
© Fraunhofer IESE
46
Eventual Consistency
is standard
Estimation - Frequency of Distribution
Trad. Enterprise IS
(ERP, CRM, Workflow Management)
Social Media Apps
(Facebook, Twitter)
Next Data-Intensive Systems
(Smart Farming, Industrie 4.0)
30%
30%
9 % 45%
4%
1%
20%
20%
20%
20%
“Technical
Immutability
Border”
Reference Aggregates
Activity Aggregates
Collaboration Result
Aggregates
Dedicated Aggregates
Derived Aggregates
Observed Aggregates
1 % 50% 20%
30 %
© Fraunhofer IESE
47
Trivial Aggregates First
n Whenever feasible, model aggregates as trivial aggregates*
B
e
s
t
P
r
a
c
t
i
c
e
P a t t e r n
A n t i - P a t t e r n
StockItems
StockItem
productId: String
number: int
1..*
1
In-place Updates
Nontrivial Activity Aggregate
GoodsReceiepts
OrderConfirmations
Observed Aggregates
StockItems
StockItem
productId: String
number: int
1
Derived Aggregate
Calculated
periodically or
on demand
Technical
Immutability
1..*
* See also: Event Sourcing & CQRS (Command Query Responsibility Segregation)
© Fraunhofer IESE
48
Dedicated Aggregates are Solitary
n Design dedicated data as self-contained aggregate
B
e
s
t
P
r
a
c
t
i
c
e
P a t t e r n
A n t i - P a t t e r n
Operation
Field Assignment DocumentationRecords
DocRecord
1..*
1
Nontrivial Activity Aggregate
Dedicated to single
user
Operation
Field Assignment
DocumentationRecords
DocRecord
1..*
1
Nontrivial Activity Aggregate
Cross-aggregate
reference
Dedicated Aggregate
1..* 1..* 1
1
1 1
1
1
1..* 1..*
© Fraunhofer IESE
49
Separation of Aggregate Classes
n Whenever feasible, keep data of different classes in separate aggregates
B
e
s
t
P
r
a
c
t
i
c
e
P a t t e r n
A n t i - P a t t e r n
Operation
Field Assignment
Nontrivial Activity Aggregate
Reference data that
is rarely updated
Operation
Field
Assignment
Nontrivial Activity Aggregate
Reference
Aggregate
Cross-aggregate reference
1..*
1..*
1..*
1
1
1
© Fraunhofer IESE
50
Derived Aggregates are idempotent
n The calculation of the state of a derived aggregate should be idempotent & deterministic
B
e
s
t
P
r
a
c
t
i
c
e
© Fraunhofer IESE
51
Do not Forget the Master
n Consider using Primary Copy Replication, if transactional guarantees are required
B
e
s
t
P
r
a
c
t
i
c
e
P a t t e r n
A n t i - P a t t e r n
Update Everywhere
Primary Copy
A
A
A
A
A A
<
A
Update Update Update Update
Update
Update
Update
A
A
A
A
A A
<
A
Update
© Fraunhofer IESE
52
Extensive Guidance in the ECD3 Domain Objects Design Guide
A n t i - P a t t e r n
Nontrivial Activity Aggregate
Field Assignment DocRecord
0..*
0..*
1
1
Job
id: Identifier
status: JobStatusEnum
OperationType
id: Identifier
name: String
StaffAssignment
MachineAssignment
Machine StaffMember
0..1
0..*
0..*
0..*
0..*
1
0..*
1
1
0..*
id: Identifier id: Identifier id: Identifier
id: Identifier id: Identifier
Dedicated to single
user
Reference data that
is rarely updated
https://github.com/EventuallyConsistentDDD/design-guidelines/blob/main/ECD3-Domain-Objects-Design-Guide-v1.2.pdf
© Fraunhofer IESE
53
Our latest Study
https://arxiv.org/pdf/2108.03758.pdf
© Fraunhofer IESE
54
More…
n Follow me on Twitter and GitHub
@susannebraun
EventuallyConsistentDDD/design-guidelines
We’ re on
Github!
Thanks!
© Fraunhofer IESE
58
#Thanx
#StayHome
Fraunhofer IESE, Kaiserslautern
Susanne Braun
Software Developer & Architect
susanne.braun@iese.fraunhofer.de
@susannebraun
EventuallyConsistentDDD/design-guidelines

More Related Content

Similar to Eventual Consistency - JUG DA

documents.pub_replication-consistency.ppt
documents.pub_replication-consistency.pptdocuments.pub_replication-consistency.ppt
documents.pub_replication-consistency.ppt
wondefirawwolile
 
Software engineering
Software engineeringSoftware engineering
Software engineering
Fahe Em
 
Software engineering
Software engineeringSoftware engineering
Software engineering
Fahe Em
 
Apache Hadoop India Summit 2011 Keynote talk "Programming Abstractions for Sm...
Apache Hadoop India Summit 2011 Keynote talk "Programming Abstractions for Sm...Apache Hadoop India Summit 2011 Keynote talk "Programming Abstractions for Sm...
Apache Hadoop India Summit 2011 Keynote talk "Programming Abstractions for Sm...
Yahoo Developer Network
 

Similar to Eventual Consistency - JUG DA (20)

Eventual Consistency – Du musst keine Angst haben
Eventual Consistency – Du musst keine Angst habenEventual Consistency – Du musst keine Angst haben
Eventual Consistency – Du musst keine Angst haben
 
OOP 2021 - Eventual Consistency - Du musst keine Angst haben
OOP 2021 - Eventual Consistency - Du musst keine Angst habenOOP 2021 - Eventual Consistency - Du musst keine Angst haben
OOP 2021 - Eventual Consistency - Du musst keine Angst haben
 
Eventual Consistency - Du musst keine Angst haben
Eventual Consistency - Du musst keine Angst habenEventual Consistency - Du musst keine Angst haben
Eventual Consistency - Du musst keine Angst haben
 
w-jax 2022: Eventual-Consistency-Du-musst-keine-Angst-haben-Final.pdf
w-jax 2022: Eventual-Consistency-Du-musst-keine-Angst-haben-Final.pdfw-jax 2022: Eventual-Consistency-Du-musst-keine-Angst-haben-Final.pdf
w-jax 2022: Eventual-Consistency-Du-musst-keine-Angst-haben-Final.pdf
 
Parallel Computing 2007: Overview
Parallel Computing 2007: OverviewParallel Computing 2007: Overview
Parallel Computing 2007: Overview
 
Keeping CALM – Konsistenz in verteilten Systemen leichtgemacht
Keeping CALM – Konsistenz in verteilten Systemen leichtgemachtKeeping CALM – Konsistenz in verteilten Systemen leichtgemacht
Keeping CALM – Konsistenz in verteilten Systemen leichtgemacht
 
chen-06.ppt
chen-06.pptchen-06.ppt
chen-06.ppt
 
This is introduction to distributed systems for the revised curiculum
This is introduction to distributed systems for the revised curiculumThis is introduction to distributed systems for the revised curiculum
This is introduction to distributed systems for the revised curiculum
 
Actor model in F# and Akka.NET
Actor model in F# and Akka.NETActor model in F# and Akka.NET
Actor model in F# and Akka.NET
 
documents.pub_replication-consistency.ppt
documents.pub_replication-consistency.pptdocuments.pub_replication-consistency.ppt
documents.pub_replication-consistency.ppt
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Role of locking- cds
Role of locking- cdsRole of locking- cds
Role of locking- cds
 
Swift Parallel Scripting for High-Performance Workflow
Swift Parallel Scripting for High-Performance WorkflowSwift Parallel Scripting for High-Performance Workflow
Swift Parallel Scripting for High-Performance Workflow
 
Konsistenz-in-verteilten-Systemen-leichtgemacht.pdf
Konsistenz-in-verteilten-Systemen-leichtgemacht.pdfKonsistenz-in-verteilten-Systemen-leichtgemacht.pdf
Konsistenz-in-verteilten-Systemen-leichtgemacht.pdf
 
Reactive: Programming -> Systems -> Architecture
Reactive: Programming -> Systems -> ArchitectureReactive: Programming -> Systems -> Architecture
Reactive: Programming -> Systems -> Architecture
 
Towards high performance computing(hpc) through parallel programming paradigm...
Towards high performance computing(hpc) through parallel programming paradigm...Towards high performance computing(hpc) through parallel programming paradigm...
Towards high performance computing(hpc) through parallel programming paradigm...
 
Apache Hadoop India Summit 2011 Keynote talk "Programming Abstractions for Sm...
Apache Hadoop India Summit 2011 Keynote talk "Programming Abstractions for Sm...Apache Hadoop India Summit 2011 Keynote talk "Programming Abstractions for Sm...
Apache Hadoop India Summit 2011 Keynote talk "Programming Abstractions for Sm...
 
Memory Matters: Drift Detection with a Low Memory Footprint for ML Models on ...
Memory Matters: Drift Detection with a Low Memory Footprint for ML Models on ...Memory Matters: Drift Detection with a Low Memory Footprint for ML Models on ...
Memory Matters: Drift Detection with a Low Memory Footprint for ML Models on ...
 
Parallel Processing Concepts
Parallel Processing Concepts Parallel Processing Concepts
Parallel Processing Concepts
 

Recently uploaded

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 

Recently uploaded (20)

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by Skilrock
 

Eventual Consistency - JUG DA

  • 1. © Fraunhofer IESE EVENTUAL CONSISTENCY Du musst keine Angst haben… Susanne Braun 18.11.2021 Java User Group Darmstadt Oder doch?
  • 2. © Fraunhofer IESE 2 Pat Helland Database & Distributed Systems Guru Architect of multiple transaction & database systems (e.g. DynamoDB) Worked at Microsoft, Amazon, SalesForce, … “There is an interesting connection between fault tolerance, offlineable systems, and the need for application-based eventual consistency.” application-based eventual consistency fault tolerance, offlineable systems Conference on Innovative Data Systems Research, 2009
  • 3. © Fraunhofer IESE 3 “Correlating” Quality Attributes Fault Tolerance Resilience Loose Coupling Availability Scalability Offline Capability Network Partition Tolerance Low Latency Responsiveness
  • 4. © Fraunhofer IESE 4 Eric Brewer Distributed Systems Researcher Coined the CAP theorem, Contributed to Spanner Prof. emeritus University of California, Berkeley, works now for Google “But we forfeit C and I of ACID for availability, graceful degradation and performance.” ACM Symposium on Principles of Distributed Computing, 2000
  • 5. © Fraunhofer IESE 5 ACID vs. BASE ACID BASE Strong Consistency (in the sense of one-copy-consistency) Isolation (in the sense of one-copy-serializability) Pessimistic Synchronization (global locks, synchronous update propagation) Global Commits (2PC, majority consensus, …) Atomicity Consistency Isolation Durability Eventual Consistency (stale data & approximate answers) Availability (top priority) Optimistic Synchronization (no locks, asynchronous update propagation) Independent Local Commits (conflict resolution, reconciliation, …) Atomicity Consistency Isolation Durability ? Database is in a consistent state & all invariants are being met! This is about Concurrency Control! This is about Convergence!
  • 6. © Fraunhofer IESE 6 Consistency vs. Isolation “Consistency tries to mask the distributed nature of the system” “Isolation tries to mask the effects of concurrent execution” Make it appear as one system! Make it appear I am the only user of the system!
  • 7. © Fraunhofer IESE 7 Douglas Terry Distributed Systems Researcher Coined the term Eventual Consistency in the 90ties Former Prof. University of California, Berkeley, worked for Microsoft, Samsung, AWS “A system providing eventual consistency guarantees that replicas would eventually converge to a mutually consistent state, i.e., to identical contents, if update activity ceased.” Int. Conference on Parallel and Distributed Information Systems, 1994
  • 8. © Fraunhofer IESE 8 Douglas Terry Distributed Systems Researcher Coined the term Eventual Consistency in the 90ties Former Prof. University of California, Berkeley, worked for Microsoft, Samsung, AWS “A system providing eventual consistency guarantees that replicas would eventually converge to a mutually consistent state, i.e., to identical contents, if update activity ceased.” Int. Conference on Parallel and Distributed Information Systems, 1994 Pragmatic Definition A system provides eventual consistency if: (1)each update operation is eventually received by each replica (2)non-commutative update operations are performed in the same order at each replica (3)the outcome of a sequence of update operations is the same at each replica (determinism) Replicated Data Management for Mobile Computing, 2008
  • 9. © Fraunhofer IESE 9 Eventual Consistency Remember: The only guarantee you get: convergence to identical state Outdated Data Conflicts Potential Concurrency Anomalies Events / Operations coming out of order Application needs to handle: Huge source of human error!
  • 10. © Fraunhofer IESE 10 Eventual Consistency Remember: You do not get any isolation guarantees like ‘Repeatable Read’ Hard to test Issues emerge randomly in production … are hard to reproduce … are hard to debug Application needs to handle concurrency control: Huge source of human error!
  • 11. © Fraunhofer IESE 11 Consistency in Non-Transactional Distributed Storage Systems Source: ACM Computing Surveys, Vol. 49, No. 1, Article 19, 2016
  • 12. © Fraunhofer IESE 12 Pat Helland Database & Distributed Systems Guru Architect of multiple transaction & database systems (e.g. DynamoDB) Worked at Microsoft, Amazon, SalesForce, … “… it is time for us to move past the examination of eventual consistency in terms of updates and storage systems. The real action comes when examining application-based operation semantics.” in terms of Reads and Writes application-based operation semantics in terms of updates and storage Conference on Innovative Data Systems Research, 2009 eventual consistency systems
  • 13. © Fraunhofer IESE 14 DDD Layered Architecture Infrastructure Layer Domain Layer Application Layer DB SELECT Statement DB UPDATE Statement Application Service Transaction Method Aggregate Repository Query Method (findBy…) Aggregate Domain Logic Method DB BOT DB EOT DIP DIP Low level Read / Write Operations Business Operations Processes, workflows Application Code Domain Model Eventual Consistency Goal Business Semantics
  • 14. © Fraunhofer IESE 15 Recap Concurrency Control in Relational DBs n A schedule of concurrent transactions is conflict-serializable iff the conflict graph is acyclic and compatible with the execution order of the conflicting operations Time R(a) W(a) R(a) W(a) R(b) W(b) R(b) W(b) Transactions T1, T2: T1 T2 Conflict graph: Conflict graph is cyclic ⇢ No conflict serializability ⇢ Schedule would be rejected
  • 15. © Fraunhofer IESE 17 Business Semantics - Banking t R(a) W(a) R(a) W(a) R(b) W(b) R(b) W(b) Withdraw(a) T1 Deposit(b) Withdraw(a) Deposit(b) T2
  • 16. © Fraunhofer IESE 18 Multilevel Transactions (Weikum et al. 1992) n If at each level the conflict serialization graph is acyclic then the multilevel schedule is in total multilevel serializable n Exploit semantics of operations in level-specific conflict relations that reflect the commutativity / compatibility of operations n Transactions are decomposed into operations and the operations again into sub-operations on multiple levels n Transactions, Business operations, Low-level read and write operations n At each level a conflict relationship is defined n read-write conflicts and write-write conflicts on the same data item conflict at the lowest level n Non-commutative operations are conflicting on the level of business operations In practice comparable to serializability! Goal: Increase number of operations that can run concurrently!
  • 17. © Fraunhofer IESE 21 Multilevel Transactions Example (Weikum et al. 1992) t R(a) W(a) R(a) W(a) R(b) W(b) R(b) W(b) Withdraw(a) T1 Deposit(b) Withdraw(a) Deposit(b) T2 Conflict graph at level of domain operations: Conflict graph at level of transactions: ⌀ 1 2 3 Low level Read / Write Operations Domain Operations Transactions Withdraw(a) Withdraw(a) Deposit(b) Deposit(b) Conflict graph is acyclic at each level! 2 1 3 2
  • 18. © Fraunhofer IESE 23 DDD Layered Architecture Infrastructure Layer Domain Layer Application Layer DB SELECT Statement DB UPDATE Statement Application Service Transaction Method Aggregate Repository Query Method (findBy…) Aggregate Domain Logic Method DB BOT DB EOT DIP DIP Low level Read / Write Operations Business Operations Processes, workflows Application Code Domain Model Eventual Consistency Goal Business Semantics
  • 20. © Fraunhofer IESE 25 Pat Helland Database & Distributed Systems Guru Architect of multiple transaction & database systems (e.g. DynamoDB) Worked at Microsoft, Amazon, SalesForce, … Conference on Innovative Data Systems Research, 2009 A C I D 2.0 Associative Commutative Idempotent Distributed (ab)c = a(bc) ab = ba aa = a Operations executed out of order…
  • 21. © Fraunhofer IESE 26 B e s t P r a c t i c e Popular Examples in Scientific Publications Commutative Operations o.domainOperation1(..) o.domainOperation2(..) = o.domainOperation2(..) o.domainOperaton1(..) ‘o’ is some Aggregate / Entity / Domain Service Counters - Integer Addition Sets – Insert Banking – Withdraw Banking – Deposit
  • 22. © Fraunhofer IESE 29 Annette Bieniusa CRDT Guru Co-Creator of AntidoteDB Worked at INRIA with Marc Shapiro, TU Kaiserslautern
  • 23. © Fraunhofer IESE 30 CRDTs are grounded in algebraic theories of monotonic semilattices Conflict-Free Replicated Data Types (CRDTs) CRDTs ship with commutative merge operations designed to be a least upper bound (LUB) of the conflicting versions. Intuitive Example: Amazon’s Shopping Card* Consider LUB as union of different object states produced at different replicas Shopping Card - Soap - Lotion Shopping Card - Lotion - Brush Merge Shopping Card - Soap - Lotion - Brush Deleted items might reappear * Werner Vogels, Communications of the ACM, Volume 52, Issue 1, 2009
  • 24. © Fraunhofer IESE 32 B e s t P r a c t i c e “Distributed” Operations Concurrent operations can be executed in a different order on different replicas. Example: Concurrent operations Domain Operations need the ability to produce intended updates if executed on different states on different replicas! Replica 1 Replica 2 Operation Operation Operation Operation Operation
  • 25. © Fraunhofer IESE 33 Collaborative Text Editing Replica 1 Replica 2 insert(6, ‘r’) insert(1, ‘e’) insert(2, ‘l’) insert(6, ‘r’) “Hlo Wold” “Hlo World” “Helo Wold” “Hello Wold” “Hello rWold”
  • 27. © Fraunhofer IESE 38 Pat Helland Database & Distributed Systems Guru Architect of multiple transaction & database systems (e.g. DynamoDB) Worked at Microsoft, Amazon, SalesForce, … “Immutability Changes Everything” ACM Queue, Volume 13, Issue 9, 2016
  • 28. © Fraunhofer IESE 40 C l a s s i f i c a t i o n 1st Level Classification of Replicated Aggregates Mutable ? Observed Aggregates* No Concurrent In-Place Updates ? Yes No Derived Aggregates* Multiple Updaters ? Yes Dedicated Aggregates Nontrivial Aggregates Yes No * “Append-Only Computing” – Helland 2015 Observed Aggregates: • Time series data (machine sensor data, market data, …) • Domain events Derived Aggregates: • Machine generated data (recommendations, …) • Timeline or newsfeed data Dedicated Aggregates: • User generated data (reviews, social media posts, ...) • Dedicated master data (user profiles, account settings) E x a m p l e s
  • 29. © Fraunhofer IESE 42 C l a s s i f i c a t i o n 2nd Level Classification of Nontrivial Aggregates Activity Aggregates Collaboration Result Aggregates Reference Aggregates Dedicated Aggregates Derived Aggregates Observed Aggregates Update Frequency in Peak Times Update Simultaneity in Peak Times Concurrency Anomaly Probability low improbable low - Nontrivial Aggregates Reference Aggregates Examples: • Master data (CRM data, resources, products, …) • Values (Valid currencies, product types, gender, …) • Meta data (Tags, descrtiptive data of raw data, ..)
  • 30. © Fraunhofer IESE 43 C l a s s i f i c a t i o n 2nd Level Classification of Nontrivial Aggregates Activity Aggregates Collaboration Result Aggregates Reference Aggregates Dedicated Aggregates Derived Aggregates Observed Aggregates Update Frequency in Peak Times Update Simultaneity in Peak Times Concurrency Anomaly Probability low high improbable probable low high - Nontrivial Aggregates Reference Aggregates Examples: • Master data (CRM data, resources, products, …) • Values (Valid currencies, product types, gender, …) • Meta data (Tags, descrtiptive data of raw data, ..) Activity Aggregates Examples: • State data of workflows, business processes, … • Coordination data of joint activities (agricultural field operation, meeting, …) • Task management data, Kanban board data, …
  • 31. © Fraunhofer IESE 44 C l a s s i f i c a t i o n 2nd Level Classification of Nontrivial Aggregates Activity Aggregates Collaboration Result Aggregates Reference Aggregates Dedicated Aggregates Derived Aggregates Observed Aggregates Update Frequency in Peak Times Update Simultaneity in Peak Times Concurrency Anomaly Probability low high very high improbable probable highly probable low high very high - Nontrivial Aggregates Reference Aggregates Examples: • Master data (CRM data, resources, products, …) • Values (Valid currencies, product types, gender, …) • Meta data (Tags, descrtiptive data of raw data, ..) Activity Aggregates Examples: • State data of workflows, business processes, … • Coordination data of joint activities (agricultural field operation, meeting, …) • Task management data, Kanban board data, … Collaboration Result Aggregates Examples: • Result data of collaborative knowledge work (CAD model, crop rotation plan, whiteboard diagram, …) • Text data as result of collaborative authorship (manuals, scientific papers, meeting protocols, …)
  • 32. © Fraunhofer IESE 45 B e s t P r a c t i c e Concurrency Anomalies Impact Assessment Concurrency Anomaly Probability Fixing Costs of Data Corruption low high very high very high high very high moderate very high moderate Reference Aggregates Activity Aggregates Collaboration Result Aggregates Dedicated Aggregates Derived Aggregates Observed Aggregates low Consequences of Data Corruption critical major critical minor depends critical Nontrivial Aggregates “Technical Immutability Border” Trivial Aggregates A Classification of Replicated Data for the Design of Eventually Consistent Domain Models, S. Braun, S. Dessloch, ICSA 2020
  • 33. © Fraunhofer IESE 46 Eventual Consistency is standard Estimation - Frequency of Distribution Trad. Enterprise IS (ERP, CRM, Workflow Management) Social Media Apps (Facebook, Twitter) Next Data-Intensive Systems (Smart Farming, Industrie 4.0) 30% 30% 9 % 45% 4% 1% 20% 20% 20% 20% “Technical Immutability Border” Reference Aggregates Activity Aggregates Collaboration Result Aggregates Dedicated Aggregates Derived Aggregates Observed Aggregates 1 % 50% 20% 30 %
  • 34. © Fraunhofer IESE 47 Trivial Aggregates First n Whenever feasible, model aggregates as trivial aggregates* B e s t P r a c t i c e P a t t e r n A n t i - P a t t e r n StockItems StockItem productId: String number: int 1..* 1 In-place Updates Nontrivial Activity Aggregate GoodsReceiepts OrderConfirmations Observed Aggregates StockItems StockItem productId: String number: int 1 Derived Aggregate Calculated periodically or on demand Technical Immutability 1..* * See also: Event Sourcing & CQRS (Command Query Responsibility Segregation)
  • 35. © Fraunhofer IESE 48 Dedicated Aggregates are Solitary n Design dedicated data as self-contained aggregate B e s t P r a c t i c e P a t t e r n A n t i - P a t t e r n Operation Field Assignment DocumentationRecords DocRecord 1..* 1 Nontrivial Activity Aggregate Dedicated to single user Operation Field Assignment DocumentationRecords DocRecord 1..* 1 Nontrivial Activity Aggregate Cross-aggregate reference Dedicated Aggregate 1..* 1..* 1 1 1 1 1 1 1..* 1..*
  • 36. © Fraunhofer IESE 49 Separation of Aggregate Classes n Whenever feasible, keep data of different classes in separate aggregates B e s t P r a c t i c e P a t t e r n A n t i - P a t t e r n Operation Field Assignment Nontrivial Activity Aggregate Reference data that is rarely updated Operation Field Assignment Nontrivial Activity Aggregate Reference Aggregate Cross-aggregate reference 1..* 1..* 1..* 1 1 1
  • 37. © Fraunhofer IESE 50 Derived Aggregates are idempotent n The calculation of the state of a derived aggregate should be idempotent & deterministic B e s t P r a c t i c e
  • 38. © Fraunhofer IESE 51 Do not Forget the Master n Consider using Primary Copy Replication, if transactional guarantees are required B e s t P r a c t i c e P a t t e r n A n t i - P a t t e r n Update Everywhere Primary Copy A A A A A A < A Update Update Update Update Update Update Update A A A A A A < A Update
  • 39. © Fraunhofer IESE 52 Extensive Guidance in the ECD3 Domain Objects Design Guide A n t i - P a t t e r n Nontrivial Activity Aggregate Field Assignment DocRecord 0..* 0..* 1 1 Job id: Identifier status: JobStatusEnum OperationType id: Identifier name: String StaffAssignment MachineAssignment Machine StaffMember 0..1 0..* 0..* 0..* 0..* 1 0..* 1 1 0..* id: Identifier id: Identifier id: Identifier id: Identifier id: Identifier Dedicated to single user Reference data that is rarely updated https://github.com/EventuallyConsistentDDD/design-guidelines/blob/main/ECD3-Domain-Objects-Design-Guide-v1.2.pdf
  • 40. © Fraunhofer IESE 53 Our latest Study https://arxiv.org/pdf/2108.03758.pdf
  • 41. © Fraunhofer IESE 54 More… n Follow me on Twitter and GitHub @susannebraun EventuallyConsistentDDD/design-guidelines We’ re on Github! Thanks!
  • 42. © Fraunhofer IESE 58 #Thanx #StayHome Fraunhofer IESE, Kaiserslautern Susanne Braun Software Developer & Architect susanne.braun@iese.fraunhofer.de @susannebraun EventuallyConsistentDDD/design-guidelines