SlideShare a Scribd company logo
Akka Persistence
and Eventuate
A CQRS/ES tool comparison
Martin Krasser (@mrt1nz)
Freelance software developer/architect
History
Eventsourced Akka Persistence
Eventuate
7.2012 9.2013 1.2015
Similarities
Basis technologies
Scala
Akka actors
Akka streams
(Pluggable) storage backends
Akka actor
Actor
State
Behavior
Mailbox
transient
non-durable
Akka Persistence
and Eventuate
Persist actor state via event sourcing
Event sourcing
Capture all changes to application
state as sequence of events
Store events in event log (append-
only)
Replay events to recover application
state
Event sourcing
Commands - actions, can fail
Events - immutable facts
Event-sourced actor
Actor
State
Behavior
Mailbox
Command handler
Event handler
Command processing
Event-sourced actor
State
Command handler
Event handler
Event log
Command processing
Event-sourced actor
State
Command handler
Event handler
Command
Event log
Command processing
Event-sourced actor
State
Command handler
Event handler
Command
Event log
Events
Command processing
Event-sourced actor
State
Command handler
Event handler
Command
Event log
Events
Events
Command processing
Event-sourced actor
State
Command handler
Event handler
Command
Event log
Events
Events
Command processing
Event-sourced actor
State
Command handler
Event handler
Command
Reply
Event log
Events
Events
State recovery
Event-sourced actor
State
Command handler
Event handler
Event log
State recovery
Event-sourced actor
State
Command handler
Event handler
Event log
Events (replay)
State recovery
Event-sourced actor
State
Command handler
Event handler
Event log
Events (replay)
Akka Persistence
and Eventuate
Separate command processing from
query processing
CQRS
Command Query

Responsibility Segregation
Different data models for command
processing and query processing
CQRS
Write model for command
processing
Read model for query

processing
CQRS
Can be well combined with event
sourcing (CQRS/ES)
CQRS/ES
Write model
Event log
Command Query
Events (r/w) Events (r)
Command side Query side
Read model
Abstractions
Command side Query side
Akka
Persistence
PersistentActor
PersistentView
Source[E,M]
Eventuate EventsourcedActor
EventsourcedView
EventsourcedProcessor
Source[E,M]
*) work in progress
PersistentActor EventsourcedActor
PersistentActor EventsourcedActor
State
PersistentActor EventsourcedActor
Command

handler
PersistentActor EventsourcedActor
Event

handler
PersistentActor EventsourcedActor
Snapshot

handler
Differences
Command side
At a glance
https://twitter.com/mrt1nz/status/573382831889653760
Consistency
Akka Persistence and Eventuate
support strong consistency
Eventuate additionally supports
relaxation to causal consistency
Akka Persistence
Enforces strong consistency on
command side
PersistentActors must be global
singletons
No actor/state replication
Eventuate
EventsourcedActors can be replicated
State replication via reliable,
asynchronous event replication
Replication across locations
(availability zones)
Replication
Location A
Location B
Location C
Replication
Location A
Application state
Location B
Location C
Replication
Events
Events
Location A
Application state
Location B
Location C
Replication
Events
Events
Location A
Application state
Location B
Location C
Replication
Command
Location A
Location B
Location C
Replication
Command
X
Location A
Location B
Location C
Replication
Command
X
Events
Events
Location A
Location B
Location C
Replication
Command
X
X
X
Events
Events
Location A
Location B
Location C
Eventuate
Replicas writeable at all locations =
multi-master
Write-availability during network
partitions
Eventuate
Write conflicts
detection
tracking
automated resolution
interactive resolution
Partition
Location A
Location B
Location C
Partition
Command
Location A
Location B
Location C
Partition
Command
X
Location A
Location B
Location C
Partition
Command
X
Events
Location A
Location B
Location C
Partition
Command
X
XEvents
Location A
Location B
Location C
Partition
Command
Command
X
XEvents
Location A
Location B
Location C
Partition
Command
Command
X
X
Y
Events
Location A
Location B
Location C
Partition
Command
Command
X
X
Y
Events
Location A
Location B
Location C
Partition
Command
Command
X
X
Y
EventsEvents
Events
Location A
Location B
Location C
Conflict
XY
XY
XY
Location A
Location B
Location C
Resolution
XY
XY
XY
Interactive
resolution
XY => Z
Location A
Location B
Location C
Resolution
XY
XY
Interactive
resolution
XY => Z
Z
Location A
Location B
Location C
Resolution
XY
XY
Interactive
resolution
XY => Z
Z
Events
Events
Location A
Location B
Location C
Resolution
Interactive
resolution
XY => Z
Z
Z
Z
Events
Events
Location A
Location B
Location C
Eventuate
Strong consistency within location*)
Causal consistency across locations
Causality is tracked with vector
clocks
*) relaxation to causal consistency also possible within location
Causal consistency
example
Distributed chat application
FIFO reliable broadcast vs.
Causal reliable broadcast
Inspired by ACM article “Don’t Settle
for Eventual Consistency”
http://queue.acm.org/detail.cfm?
id=2610533
Causal consistency
example
FIFO rel. broadcast
DC1
DC2
DC3
FIFO rel. broadcast
- Alice: Lost my wedding ring
Alice
DC1
DC2
DC3
FIFO rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
Alice
DC1
DC2
DC3
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
Alice
- Alice: Whew, found it upstairs
DC1
DC2
DC3
FIFO rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
Alice
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
DC1
DC2
DC3
FIFO rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
Alice
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
DC1
DC2
DC3
FIFO rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
Bob
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
DC1
DC2
DC3
FIFO rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
Bob
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
DC1
DC2
DC3
FIFO rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
DC1
DC2
DC3
Bob
FIFO rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
DC1
DC2
DC3
FIFO rel. broadcast
Causality violation!
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
- Alice: Whew, found it upstairs
DC1
DC2
DC3
FIFO rel. broadcast
Retry
Causality violation!
Causal rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
DC1
DC2
DC3
Causal rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
Bob
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
DC1
DC2
DC3
Causal rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
Bob
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
Causality

check
DC1
DC2
DC3
Causal rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
Bob
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
Causality

check
DC1
DC2
DC3
Causal rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
Bob
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
Causality

check
Causality

check
DC1
DC2
DC3
Causal rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
Bob
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
Buffer
Causality

check
Causality

check
DC1
DC2
DC3
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
Buffer
Causality

check
Retry
DC1
DC2
DC3
Causal rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
Buffer
Causality

check
- Alice: Whew, found it upstairs
Retry
DC1
DC2
DC3
Causal rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
Buffer
Causality

check
- Bob: I’m glad to hear that
- Alice: Whew, found it upstairs
Retry
DC1
DC2
DC3
Causal rel. broadcast
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Lost my wedding ring
- Alice: Whew, found it upstairs
- Alice: Whew, found it upstairs
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
- Bob: I’m glad to hear that
- Alice: Whew, found it upstairs
Causal re-ordering
DC1
DC2
DC3
Causal rel. broadcast
Causal consistency
Causally related events are
delivered in same order at all
locations
Concurrent events can be delivered
in any order at different locations
Differences
Event log
“Local”
event log
Eventuate
- LevelDB
- Cassandra
Location A
Location B
Location C
“Local”
event log
“Replicated”
event log
Eventuate
- LevelDB
- Cassandra
Location A
Location B
Location C
- LevelDB
- Cassandra
EventsEvents
Events
Local event log
Storage order consistent with

causal order
Given the potential causality
relation ➞ of events
Local event logs are linear
extensions of ➞
Replicated event log
Same causal event storage order 

at different locations
Different total event storage order 

at different locations
Akka Persistence
- LevelDB
- Cassandra
- EventStore
- MongoDB
- Kafka
- …
Location A
Location B
Location C
Differences
Event collaboration
Akka Persistence
PA
PA
PA
PA
Event log:
private for writing
shared for reading
(query side)
Eventuate
EA
EA
EA
Event log:
shared for writing
shared for reading
EA
Event routing
EA
EA
EA
Event routing
EA
EA
EA
e1
Event routing
EA
EA
EA
e1
e1
Event routing
EA
EA
EA
e1
e1
All
Topic
Aggregate id
…
Event routing
EA
EA
EA
e1
e1
EAEA
e1
EA
e1
Location A
Location B
Location C
Event collaboration
State replication
Service interaction
Event collaboration
S2
S1
S1
S3
Location A
Location B
Location C
Event collaboration
S2
S1
e1
S1
S3
Location A
Location B
Location C
Event collaboration
S2
S1
e1
S1
e1
S3
Location A
Location B
Location C
Event collaboration
S2
S1
e1
e1
S1
e1
S3
e1
Location A
Location B
Location C
Event collaboration
S2
S1
e1
e1
S1
e1
S3
e1
Location A
Location B
Location C
e2
Event collaboration
S2
S1
e1
e1
S1
e1
S3
e1
Location A
Location B
Location C
e2
e2
Event collaboration
Reliable, distributed and partition-
tolerant business processes
Event-driven (micro-)service
architectures
Event collaboration
Reliable event delivery
Causal event delivery
De-duplicated event stream
Differences
Query side
Akka Persistence 2.3
PA
PA
PV
PV
PV
PersistentViews on single PersistentActor

(default)
Akka Persistence 2.4
PA
PA
S
S
S
Stream Sources for multiple PersistentActors

(requires storage plugin support)
Eventuate
EV
EV
EventsourcedViews on multiple EventsourcedActors

(default, shared local log)
EA
EA
EA
Eventuate
EV
EV
EventsourcedViews on multiple EventsourcedActors

(default, shared replicated log)
EA
EA
EA
EA
EAEA
Location A
Location B
Location C
Consistency in CQRS
Eventual
consistency
Causal
consistency
Akka
Persistence
usually per PA
(plugin-specific)
Eventuate
Causal consistency
Single EA/EV: default
Across EA/EV: conditional requests
Example scenario
Update a write model (EA)
Query a read model (EV)
Query result should include effect
that was caused by the update
Conditional request
EA
Location A
EV
Location B
Conditional request
EA
Location A
EV
Location B
cmd
Conditional request
EA
Location A
EV
Location B
evt
cmd
Conditional request
EA
Location A
EV
Location B
evt
evt(vts)
cmd
vts = vector timestamp (a “condition”)
Conditional request
EA
Location A
EV
Location B
evt
evt(vts)
cmd reply(vts)
vts = vector timestamp (a “condition”)
Conditional request
EA
Location A
EV
Location B
evt
evt(vts)
cmd CR(query, vts)reply(vts)
vts = vector timestamp (a “condition”)
Conditional request
EA
Location A
EV
Location B
evt
evt(vts)
cmd CR(query, vts)reply(vts)
vts = vector timestamp (a “condition”)
delay
Conditional request
EA
Location A
EV
Location B
evt
evt(vts)
cmd CR(query, vts)reply(vts)
vts = vector timestamp (a “condition”)
delay
Conditional request
EA
Location A
EV
Location B
evt
evt(vts)evt(vts)
cmd CR(query, vts)reply(vts)
vts = vector timestamp (a “condition”)
delay
Conditional request
EA
Location A
EV
Location B
evt
evt(vts)evt(vts)
cmd CR(query, vts)reply(vts)
vts = vector timestamp (a “condition”)
deliver
Conditional request
EA
Location A
EV
Location B
evt
evt(vts)evt(vts)
cmd CR(query, vts)reply(vts)
vts = vector timestamp (a “condition”)
reply
deliver
Akka Distributed Data
and Eventuate
CRDTs
CRDTs
Conflict-free Replicated Data Types
Automated resolution of write conflicts
CRDTs
Akka distributed data: CvRDTs

(convergent or state-based)
Eventuate: CmRDTs

(commutative or operation-based)
CRDTs
CvRDTs CmRDTs
Message
payload
Current state Operations
Communication
middleware
No guarantees
Reliable
broadcast
(idempotent)
Change
history
CvRDT intern Persistent log
Specification
“A comprehensive study of
Convergent and Commutative
Replicated Data Types”
http://hal.upmc.fr/docs/00/55/55/88/
PDF/techreport.pdf
Akka CvRDTs
10 implemented from specification

(incl. counters, registers, sets, maps)
In-memory only (non-durable)
Custom data types can be defined
Eventuate CmRDTs
4 implemented from specification

(Counter, MV/LWW-register, OR-Set)
Durable via event sourcing
Eventuate CRDT framework
Documentation
http://rbmhtechnology.github.io/eventuate/
http://doc.akka.io/docs/akka/2.4.0/scala/
persistence.html
http://doc.akka.io/docs/akka/2.4.0/scala/
persistence-query.html
http://doc.akka.io/docs/akka/2.4.0/scala/
distributed-data.html
Thank you!

More Related Content

PDF
Akka persistence == event sourcing in 30 minutes
PDF
Developing microservices with aggregates (SpringOne platform, #s1p)
PDF
Microservices + Events + Docker = A Perfect Trio (dockercon)
PDF
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
PDF
A pattern language for microservices (#gluecon #gluecon2016)
PDF
Event-sourced architectures with Akka
PDF
Akka in Practice: Designing Actor-based Applications
ODP
Akka Persistence | Event Sourcing
Akka persistence == event sourcing in 30 minutes
Developing microservices with aggregates (SpringOne platform, #s1p)
Microservices + Events + Docker = A Perfect Trio (dockercon)
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
A pattern language for microservices (#gluecon #gluecon2016)
Event-sourced architectures with Akka
Akka in Practice: Designing Actor-based Applications
Akka Persistence | Event Sourcing

Viewers also liked (20)

PPTX
CQRS + ES with Scala and Akka
PDF
Resilient Applications with Akka Persistence - Scaladays 2014
PDF
Akka in Production - ScalaDays 2015
PDF
Akka persistence webinar
ODP
An Introduction to Akka http
PDF
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
PDF
Securing Microservices using Play and Akka HTTP
PDF
Understanding Akka Streams, Back Pressure, and Asynchronous Architectures
PDF
Akka and the Zen of Reactive System Design
PDF
Building Reactive Systems with Akka (in Java 8 or Scala)
ODP
Akka Finite State Machine
PDF
Prolog Visualizer
PDF
Microservices 101: Exploiting Reality's Constraints with Technology
PDF
Fluent-bit
PDF
#hacksummit 2016 - event-driven microservices – Events on the outside, on the...
PDF
DSR Microservices (Day 1, Part 2)
PPTX
Scala + Akka + ning/async-http-client - Vancouver Scala meetup February 2015
PDF
scalaphx-akka-http
PPT
A csodák logikája
PDF
Codemotion akka persistence, cqrs%2 fes y otras siglas del montón
CQRS + ES with Scala and Akka
Resilient Applications with Akka Persistence - Scaladays 2014
Akka in Production - ScalaDays 2015
Akka persistence webinar
An Introduction to Akka http
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Securing Microservices using Play and Akka HTTP
Understanding Akka Streams, Back Pressure, and Asynchronous Architectures
Akka and the Zen of Reactive System Design
Building Reactive Systems with Akka (in Java 8 or Scala)
Akka Finite State Machine
Prolog Visualizer
Microservices 101: Exploiting Reality's Constraints with Technology
Fluent-bit
#hacksummit 2016 - event-driven microservices – Events on the outside, on the...
DSR Microservices (Day 1, Part 2)
Scala + Akka + ning/async-http-client - Vancouver Scala meetup February 2015
scalaphx-akka-http
A csodák logikája
Codemotion akka persistence, cqrs%2 fes y otras siglas del montón
Ad

Similar to Akka Persistence and Eventuate (11)

PDF
Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011
PDF
The Power Of Event Chapter 5
PDF
Distributed Computing
PPT
Aaai 2011 event processing tutorial
PPTX
A detailed description about Cryptography explaining the topic from the very ...
PPT
Fuzzy causal order
PDF
time-clocks.pdf
PPT
Interop Concepts Dhs Preso Contestabile 09 27 11
PPTX
TeleCom Lecture 02.pptx
KEY
Eventually Consistent Data Structures (from strangeloop12)
PDF
Artificial Intelligence 06.2 More on Causality Bayesian Networks
Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011
The Power Of Event Chapter 5
Distributed Computing
Aaai 2011 event processing tutorial
A detailed description about Cryptography explaining the topic from the very ...
Fuzzy causal order
time-clocks.pdf
Interop Concepts Dhs Preso Contestabile 09 27 11
TeleCom Lecture 02.pptx
Eventually Consistent Data Structures (from strangeloop12)
Artificial Intelligence 06.2 More on Causality Bayesian Networks
Ad

Recently uploaded (20)

PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPT
Introduction Database Management System for Course Database
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
history of c programming in notes for students .pptx
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
ai tools demonstartion for schools and inter college
PDF
Understanding Forklifts - TECH EHS Solution
PDF
AI in Product Development-omnex systems
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
medical staffing services at VALiNTRY
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Design an Analysis of Algorithms I-SECS-1021-03
Introduction Database Management System for Course Database
Softaken Excel to vCard Converter Software.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
history of c programming in notes for students .pptx
VVF-Customer-Presentation2025-Ver1.9.pptx
How Creative Agencies Leverage Project Management Software.pdf
Operating system designcfffgfgggggggvggggggggg
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Odoo POS Development Services by CandidRoot Solutions
Navsoft: AI-Powered Business Solutions & Custom Software Development
ai tools demonstartion for schools and inter college
Understanding Forklifts - TECH EHS Solution
AI in Product Development-omnex systems
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Wondershare Filmora 15 Crack With Activation Key [2025
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
medical staffing services at VALiNTRY
Lecture 3: Operating Systems Introduction to Computer Hardware Systems

Akka Persistence and Eventuate