This document discusses using CQRS and event sourcing on AWS. It highlights that the approach allows flexibility in data structures and enables learning from events and matches over time. While there are many components, it provides a scalable and flexible system. However, the separation of write and read capabilities may introduce some latency. Overall, CQRS and event sourcing on AWS is presented as a good fit for applications that require flexible data schemas and the ability to learn from historical events and user interactions.
11. "I think customers should
stop expecting that there
are always melons
available at the
supermarket."
11
12. "I was wondering last
christmas that the whole
Amazon delivery business
still worked. I expected it to
break because of missing
drivers... maybe next time."
12
29. THE DECISIONSTHE DECISIONS
Event sourcing for flexible data structures and for
learning from matches
AWS for a flexible base that provides a rich toolbelt
and high availability
29
30. Browser
API Gateway API Gateway
Command
Event
Event
Dynamo DB
S3 Backup
Event Event Event
Event
Command
Lambdas
View
Projection
Lambdas
Redis
cache
View View
View
30
31. Browser
API Gateway API Gateway
Command
Event
Event
Dynamo DB
S3 Backup
Event Event Event
Event
Command
Lambdas
View
Projection
Lambdas
Redis
cache
View View
View
READWRITE
31
36. Command
Event
APPLY EVENT TO JOBAPPLY EVENT TO JOB
AGGREGATEAGGREGATE
events/addedJobContact.js
import {defineEvent} from 'cqrs-domain'
export const event = defineEvent(
{ payload: 'payload' },
(data, aggregate) => {
let contacts = []
if (aggregate.has('contacts')) {
contacts = aggregate.get('contacts')
}
aggregate.set(
'contacts',
contacts.concat(data)
)
})
36
37. Command
Event
DISADVANTAGES OF THEDISADVANTAGES OF THE
WRITE SIDEWRITE SIDE
Consumption only => HTTP 202 ACCEPTED
One Command, one Lambda (one Log, one
Command definition, one Event definition)
37
38. Command
Event
ADVANTAGES OF THE WRITEADVANTAGES OF THE WRITE
SIDESIDE
Data structures can be relaxed or restricted
by schemas
Incoming data can be mangled on different
levels
Supports DDD approach and the domain
model represents real world actions
38
39. Browser
API Gateway API Gateway
Command
Event
Event
Dynamo DB
S3 Backup
Event Event Event
Event
Command
Lambdas
View
Projection
Lambdas
Redis
cache
View View
View
READWRITE
39
40. Event
View
View View
View
For each new event ...
... fetch current view from Redis
... apply event to view
... store updated view in Redis
On (updated view) OR
(GET /job/JOB-UUID) ...
... fetch views from Redis
... aggregate to view
... (push) OR (provide) response
40
46. Event
View
View View
View
DISADVANTAGES OF THEDISADVANTAGES OF THE
READ SIDEREAD SIDE
All the downsides of handling an event
log KanDDDinsky 2017: An Event Sourcing Retrospective
Developing a view requires coding view
builders / event denormalizers.
Asynchronous pipeline
46
47. Event
View
View View
View
ADVANTAGES OF THEADVANTAGES OF THE
READ SIDEREAD SIDE
Response data can be built on different
levels
You can iterate optimizations from
frontend, to view lambda, to event
projections
Scalable
Push model by default
47
48. Browser
API Gateway API Gateway
Command
Event
Event
Dynamo DB
S3 Backup
Event Event Event
Event
Command
Lambdas
View
Projection
Lambdas
Redis
cache
View View
View
48
49. SUMMARY - DISADVANTAGESSUMMARY - DISADVANTAGES
Write and read are seperate and may be slow
Many bits and pieces
Can be "Garbage in, garbage out"
49
50. SUMMARY - ADVANTAGESSUMMARY - ADVANTAGES
FLEXIBLEFLEXIBLE
Mangle data anywhere
Frontend (product) may rule
Scalable
LEARNINGLEARNING
Enables learning from day one
Makes your data analysts happy
Deals with real world events
50