SlideShare a Scribd company logo
Fundamentals of
Event-Driven Microservices
Table of Contents
Part 1: Problems, Communication, and Event-Driven basics
Part 2: Event Modelling, Schemas, & Bootstrapping Domain Data
Part 3: Service Modelling, Using the DCL, & Examples
System Architectures
It’s all tradeoffs
Modern Problems
Big-Data Scale
(Near-) Real Time updates
Coupling
How do we handle these
issues in the real world?
First, let’s look at
Communication Structures
Communication Structures
• Business
• Implementation
• Data
Business Communication Structure
What do we do to
achieve our business goals?
fundamentalsofeventdrivenmicroservices11728489736099.pdf
fundamentalsofeventdrivenmicroservices11728489736099.pdf
fundamentalsofeventdrivenmicroservices11728489736099.pdf
Implementation Communication
Structure
How do we optimize the processes
that lead to our business goals?
fundamentalsofeventdrivenmicroservices11728489736099.pdf
Data Communication Structures
How do we get the data we need
for our business processes?
fundamentalsofeventdrivenmicroservices11728489736099.pdf
The Implementation
Communication Structure
Also, The Data
Communication Structure!
Ad-hoc Data Communication Structures
Synchronous Services can be
used to help solve these problems
Synchronous Services
Fan-Out
Scaling Issues
Boundary & Implementation Issues
Where do Synchronous Services work well?
Many companies succeed
with synchronous services!
It’s all about tradeoffs
What about Event-Driven
Architectures?
Events are Business Facts
Example
E-commerce
• Stores, Merchants, Products, Users, Accounts
Shipping
• Warehouses, Orders, Shipments, Drivers, Trucks
Product A has 100 units of stock
User A has placed an order, ID=1234
Merchant 100’s minimum order amount is $50
Publish the Facts
Single-Source of Truth
The Event-Broker stores all
events and event streams
The Event Stream
(Immutable Log)
Partitions for Scalability and Data Locality
Producer Responsibilities
Partitioning
Producer Responsibilities
Consistency
Single-Writer Principle
Single-Schema Principle
Consumer Responsibilities
Offsets
Consumer Responsibilities
State
Principle
Treat domain event data
as a first-class citizen
Does this mean everything should
be written to an event-stream?
No
Event Types & Streams
1) Entity
2) Keyed Event
3) Unkeyed Event
1) Entity
VIN MAKE MODEL COLOUR
A1 Ford F150 Tan
B2 Toyota Camry Gold
Cars
ID FIRST LAST
123 Adam Bellemare
444 Guy Incognito
People
Key Value
An entity has
a unique key
VIN is Key
Materialize Entities into Each Service
Each event is the
current state of
a (keyed) entity!
Partition 0
Overwrite
“9” with “2”
2) Keyed Events
VIN INFRACTION AMOUNT DATE DRIVER_ID
A1 Speeding $150 2018-10-07 123
A1 Parking $25 2018-11-11 123
B2 Parking $25 2018-11-13 444
Tickets Issued
Key Value
Multiple events
with same VIN
2) Keyed Events
VIN INFRACTION AMOUNT DATE DRIVER_ID
A1 Speeding $150 2018-10-07 123
A1 Parking $25 2018-11-11 123
B2 Parking $25 2018-11-13 444
Tickets Issued
Key Value
Multiple events
with same VIN
“This ticket belongs to VIN ID X”
Aggregating State from Keyed Events
Keyed by Shape
Partition 0
Partition 1
Instance 1
Instance 0
eg: Total
Ticket Costs
3) Unkeyed Events
LICENSE PLATE CAMERA_ID DATETIME IMAGE_URI
ZXJ123 123 2020-07-07… s3://…
ABC123 234 2020-07-08… hdfs://…
ACBZ900 345 2020-07-08… c:/program…
Intersection Traffic Camera
Value
3) Unkeyed Events
LICENSE PLATE CAMERA_ID DATETIME IMAGE_URI
ZXJ123 123 2020-07-07… s3://…
ABC123 234 2020-07-08… hdfs://…
ACBZ900 345 2020-07-08… c:/program…
Not that Common - Usually have a key!
Value
May be found in “dumb” data pipelining
A Simple Enrichment Example
Cars
Tickets
Ticket $
per Car
1) Materialize
1) Aggregate
2) Join
3) Emit
Break
Part 2: Event Modelling, Schemas,
& Bootstrapping Domain Data
“The fundamental problem of communication is that of
reproducing at one point, either exactly or approximately,
a message selected at another point.”
- Claude Shannon, Father of Communication Theory
Modelling Events using
Domain-Driven Design
Modelling Events
What business occurrence
does this event represent?
Event Modelling Example
SALES FACTS
FK ITEM_ID
FK STORE_ID
PRICE
PAYMENT
ITEM DIMENSIONS
PK ITEM_ID
NAME
BRAND
CATEGORY
STORE DIMENSIONS
PK STORE_ID
STORE_NAME
ADDRESS
CATEGORY
Entity Stream
Store Stream
Key: Store_Id
Event Stream
Sales Stream
Key: N/A
Entity Stream
Item Stream
Key: Item_Id
Event Modelling Example - Alternative
SALES FACTS
PK SALES_ID
FK ITEM_ID
FK STORE_ID
PRICE
PAYMENT
ITEM DIMENSIONS
PK ITEM_ID
NAME
BRAND
CATEGORY
STORE DIMENSIONS
PK STORE_ID
STORE_NAME
ADDRESS
CATEGORY
Entity Stream
Store Stream
Key: Store_Id
Entity Stream
Item Stream
Key: Item_Id
Sales Stream
Key: Sales_Id
Entity Stream
Event Modelling Example - Denormalized
SALES FACTS
PK SALES_ID
FK ITEM_ID
FK STORE_ID
PRICE
PAYMENT
ITEM DIMENSIONS
PK ITEM_ID
NAME
BRAND
CATEGORY
STORE DIMENSIONS
PK STORE_ID
STORE_NAME
ADDRESS
CATEGORY
Enriched Sales Stream
Key: Sales_Id
Merged Entity Stream
Join Join
Unstructured Data
A recipe for disaster
Unstructured Big Data
Real-life bloopers
isScreenOn: “yes” “no” 1 0 true false null
productId: null 1234 “null” “<null>” “%3cnull%3e”
premium: true false 4040 null “null”
Consumer Pain
Schemas
ID (INTEGER)
COLOUR (NULL,
STRING) DEFAULT: NULL
TIME (DATETIME)
100 Red 2020-08-08…
200 NULL 2020-08-08…
Producer Responsibility:
Create events that
match the schema
Schema Options
• Apache Avro
• Google’s Protobuf
• JSONSchema (not plain JSON!)
(Almost) self-documenting
{
"type" : "record",
"name" : "User",
"namespace" : "com.example",
"fields" : [
{"name": "username", "type": “string"},
{"name": "phone", "type": [null,"int"], "default" : null},
{"name": "address", "type": "string", "default": “UNKNOWN"},
{"name": "country", "type": "enum", "symbols": ["CA", "US", "OTHER"],
"doc" : "The user's country. Select other if not in list"}
]
}
Schema Evolution
Consuming & Converting Events
Backwards Compatible
Can convert a V2 event
to V3 format at Consumer
Forwards Compatible
Can convert a V3 event
to V2 format at Consumer
Full Transitive
Serialization & Transmission
Schema Registry
Schema Registry
Enable Data Discovery
Schema Breaking Change
Breaking Changes
New Streams
New offsets
Migrating consumers
Reprocessing
Halfway-Mark: Questions?
Event-Broker Options
Criteria
• Performance & Throughput
• Indefinite retention
• Tiered storage
• Security & Access Control
• Adoption & Open Source
• 3rd-party options and tools
Stream Retention
•Indefinite
•Time-based
•Size-based
Indefinite Retention
It’s just bytes on disk!
Tiered Storage
Put those bytes in the Cloud!
Security and Access Control
• Secure / Encrypted connections
• Data Encryption (Field Level Encryption!)
• Access Control Lists (ACLs)
• Enforce single-writer principle
• Track stream ownership and subscriptions
Adoption & Open Source
• Avoid vendor lock-in
• Hire talent
• Fix own issues
• Extended network
3rd Party Options & Tools
• Schema Registry
• Stream Access & Visualization Tooling
• Change-Data Capture Tooling
• Hosting
Options
Apache Kafka
Apache Pulsar
AWS Kinesis
Azure Event Hub
Google Pub Sub
Limited Retention
(2-52 Weeks)
Small Community
Tiered Storage
Tiered Storage
(OSS & Private)
Populating Event Streams
for Data Communication
What is it that we’re willing to do
to provide reliable domain data?
Principle:
Use the event-broker
as the single source of truth
Forked-Write Anti-Pattern
Independent
Data Store
Independent
Data Store
Forked-Write Anti-Pattern
Forked-Write Anti-Pattern
Can’t write to both data stores atomically!
Forked-Write Anti-Pattern
Forked-Write Anti-Pattern
Forked-Write Anti-Pattern
Forked-Write Anti-Pattern
Forked-Write Anti-Pattern
What else can we do?
Transactional Outbox
Transactional Outbox
Transactional Outbox
Transactional Outbox
Works!
But can be challenging to set up!
Pattern: Materialize after Write
Pattern: Materialize after Write
Question
Won’t these options slow down the application?
Liberating Data from Legacy Systems
Connectors & Change-Data Capture
Connectors & CDC Pros
Flexible Scalable
Single Source of Truth
Connectors & CDC Cons
Idiosyncracies
Overhead
Performance
Impact
Coupling on Internal
Data Model
Brittle & Reactive
It’s not one or the other!
Point-to-Point or Event-Driven?
Event Streams are part of the API
Questions?
Part 3: Service Modelling,
Using Event Streams, & Examples
The Microservice Tax
Event Stream Requirements
Paying the tax lets your users
focus on building the services
How do you model your services?
Use Domain-Driven Design (again)
Modelling Services
Build services around
business functions
Consider the Modular Monolith
fundamentalsofeventdrivenmicroservices11728489736099.pdf
Modelling Services
It’s an art as
much as a science
Eg Workflows built from Services
Let’s look at a subset
Payment Processing
Payment Processing
Payment Processing
KEY VALUE
OrderId List(ItemId)
CustomerInfo
KEY VALUE
OrderId List(ItemId)
CustomerInfo
PaymentResults
KEY VALUE
OrderId PaymentFailureInfo
PaymentAPIInfo
Payment Processing
KEY VALUE
OrderId List(ItemId)
CustomerInfo
KEY VALUE
OrderId List(ItemId)
CustomerInfo
KEY VALUE
OrderId PaymentInfo
KEY VALUE
OrderId PaymentResults
Service Decides Payment Failure
Try 3 times Failed 3 times
Payment Processing: Internal State
Payment Processing: Internal State
Restoring Internal State
Idempotent Processing
Reduce Complexity with Field-Level Encryption
Reduce Complexity with Field-Level Encryption
KEY VALUE
OrderId List(ItemId)
CustomerInfo
//Encrypted
PaymentInfo
(CC, Address, etc)
Only Authorized Services
can Decrypt the Fields!
Reduce Complexity with Field-Level Encryption
KEY VALUE
OrderId List(ItemId)
CustomerInfo
//Encrypted
PaymentInfo
(CC, Address, etc)
KEY VALUE
OrderId PaymentFailureInfo
PaymentAPIInfo
//Encrypted
PaymentResults
Only Authorized Services
can Decrypt the Fields!
Fulfillment Service Example
Expanded
Schemas
KEY VALUE
OrderId List(ItemId)
CustomerInfo
KEY VALUE
ItemId Map(Location,Quantity)
KEY VALUE
OrderId Location
FulfimentInfo
List(ItemId)
CustomerInfo
Fulfillment Workflow Pt.1
(Automated)
High-Priority Materialization!
Fulfillment Workflow Pt.2
(Manual)
Unfulfilled?
Compensation
KEY VALUE
FulfimentId Location
OrderId
List(ItemId)
CustomerInfo
KEY VALUE
OrderId State
List(ItemId)
CustomerInfo
Augmented Compensation Workflow
In Conclusion…
Event streams as the DCL
Event Streams: The Data Communication Layer
Business Communications
Services Align with Business
fundamentalsofeventdrivenmicroservices11728489736099.pdf
Questions, please!

More Related Content

PDF
Designing Events-First Microservices For A Cloud Native World
PDF
Designing Events-first Microservices
PPTX
Spring I_O 2024 - Flexible Spring with Event Sourcing.pptx
PDF
Building an Event-Driven Data Mesh (Early Release) Adam Bellemare
PDF
Building an Event-Driven Data Mesh (Early Release) Adam Bellemare
PPTX
Brown bag eventdrivenmicroservices-cqrs
PDF
Event Sourcing - what could possibly go wrong?
PPTX
Understanding event data
Designing Events-First Microservices For A Cloud Native World
Designing Events-first Microservices
Spring I_O 2024 - Flexible Spring with Event Sourcing.pptx
Building an Event-Driven Data Mesh (Early Release) Adam Bellemare
Building an Event-Driven Data Mesh (Early Release) Adam Bellemare
Brown bag eventdrivenmicroservices-cqrs
Event Sourcing - what could possibly go wrong?
Understanding event data

Similar to fundamentalsofeventdrivenmicroservices11728489736099.pdf (20)

PDF
CQRS and Event Sourcing with MongoDB and PHP
PDF
Designing Events-first Microservices
PPTX
Event Sourcing & CQRS: Down the rabbit hole
KEY
Event Driven Architecture
PDF
Event Driven-Architecture from a Scalability perspective
PDF
Citi Tech Talk: Event Driven Kafka Microservices
PPTX
Managing Data at Scale - Microservices and Events
PDF
A year with event sourcing and CQRS
PDF
Andrzej Ludwikowski - Event Sourcing - co może pójść nie tak?
PPTX
Data Modeling for IoT and Big Data
PDF
You Put *What* in Your Stream?! Patterns and Practices for Event Design with ...
PDF
What if we stored events instead of state?
PDF
Handling eventual consistency in a transactional world with Matteo Cimini and...
PDF
Kafka Summit 2022: Handling Eventual Consistency in a Transactional World.pdf
PDF
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
PPTX
Gr8conf US 2015 - Intro to Event Sourcing with Groovy
PDF
#JaxLondon: Building microservices with Scala, functional domain models and S...
PDF
Building Microservices with Scala, functional domain models and Spring Boot -...
PPTX
Real World Event Sourcing and CQRS
PDF
Building and deploying microservices with event sourcing, CQRS and Docker (Ha...
CQRS and Event Sourcing with MongoDB and PHP
Designing Events-first Microservices
Event Sourcing & CQRS: Down the rabbit hole
Event Driven Architecture
Event Driven-Architecture from a Scalability perspective
Citi Tech Talk: Event Driven Kafka Microservices
Managing Data at Scale - Microservices and Events
A year with event sourcing and CQRS
Andrzej Ludwikowski - Event Sourcing - co może pójść nie tak?
Data Modeling for IoT and Big Data
You Put *What* in Your Stream?! Patterns and Practices for Event Design with ...
What if we stored events instead of state?
Handling eventual consistency in a transactional world with Matteo Cimini and...
Kafka Summit 2022: Handling Eventual Consistency in a Transactional World.pdf
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
Gr8conf US 2015 - Intro to Event Sourcing with Groovy
#JaxLondon: Building microservices with Scala, functional domain models and S...
Building Microservices with Scala, functional domain models and Spring Boot -...
Real World Event Sourcing and CQRS
Building and deploying microservices with event sourcing, CQRS and Docker (Ha...
Ad

Recently uploaded (20)

PPTX
Information Storage and Retrieval Techniques Unit III
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PDF
August 2025 - Top 10 Read Articles in Network Security & Its Applications
PPTX
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
Module 8- Technological and Communication Skills.pptx
PDF
737-MAX_SRG.pdf student reference guides
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PPT
Total quality management ppt for engineering students
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
introduction to high performance computing
PPTX
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
Information Storage and Retrieval Techniques Unit III
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
Exploratory_Data_Analysis_Fundamentals.pdf
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
August 2025 - Top 10 Read Articles in Network Security & Its Applications
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
Visual Aids for Exploratory Data Analysis.pdf
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
III.4.1.2_The_Space_Environment.p pdffdf
Module 8- Technological and Communication Skills.pptx
737-MAX_SRG.pdf student reference guides
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
R24 SURVEYING LAB MANUAL for civil enggi
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
Total quality management ppt for engineering students
Automation-in-Manufacturing-Chapter-Introduction.pdf
introduction to high performance computing
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
Ad

fundamentalsofeventdrivenmicroservices11728489736099.pdf