1) The document discusses using streaming platforms like Kafka Streams to build event-driven microservices architectures. It notes the tension between sharing data through databases versus loosely coupling services.
2) Services can share data by publishing domain events to a streaming platform instead of directly calling each other. The streaming platform acts as the system of record storing events indefinitely.
3) Data can be materialized from the event stream into views/tables inside services as needed through streaming queries. This allows querying the system of record without moving data.
6. 6
CREATE STREAM possible_fraud AS
SELECT card_number, count(*)
FROM authorization_attempts
WINDOW TUMBLING (SIZE 5 MINUTE)
GROUP BY card_number
HAVING count(*) > 3;
authorization_attempts possible_fraud
7. 7
CREATE STREAM possible_fraud AS
SELECT card_number, count(*)
FROM authorization_attempts
WINDOW TUMBLING (SIZE 5 MINUTE)
GROUP BY card_number
HAVING count(*) > 3;
authorization_attempts possible_fraud
8. 8
CREATE STREAM possible_fraud AS
SELECT card_number, count(*)
FROM authorization_attempts
WINDOW TUMBLING (SIZE 5 MINUTE)
GROUP BY card_number
HAVING count(*) > 3;
authorization_attempts possible_fraud
9. 9
CREATE STREAM possible_fraud AS
SELECT card_number, count(*)
FROM authorization_attempts
WINDOW TUMBLING (SIZE 5 MINUTE)
GROUP BY card_number
HAVING count(*) > 3;
authorization_attempts possible_fraud
10. 10
CREATE STREAM possible_fraud AS
SELECT card_number, count(*)
FROM authorization_attempts
WINDOW TUMBLING (SIZE 5 MINUTE)
GROUP BY card_number
HAVING count(*) > 3;
authorization_attempts possible_fraud
11. 11
CREATE STREAM possible_fraud AS
SELECT card_number, count(*)
FROM authorization_attempts
WINDOW TUMBLING (SIZE 5 MINUTE)
GROUP BY card_number
HAVING count(*) > 3;
authorization_attempts possible_fraud
24. 24
Service Database
Data on
inside
Data on
outside
Data on
inside
Data on
outside
Interface
hides data
Interface
amplifies
data
Databases amplify the data they hold
27. 27
Tension
We want all the good stuff which comes
with a database.
We don’t want to share that database
with anyone else.
But we do want to share datasets in a
sensible way.
28. 28
So how do we share data between
services?
Orders
Service
Shipping
Service
Customer
Service
Webserver
29. 29
Buying an iPad (with REST)
Submit
Order
shipOrder() getCustomer()
Orders
Service
Shipping
Service
Customer
Service
Webserver
30. 30
Buying an iPad with Events
Message Broker (Kafka)
Notification Data is
replicated
(incrementally)
Submit
Order
Order
Created
Customer
Updated
Orders
Service
Shipping
Service
Customer
Service
Webserver
KAFKA
31. 31
Events for Notification Only
Message Broker (Kafka)
Submit
Order
Order
Created
getCustomer()
REST
Notification
Orders
Service
Shipping
Service
Customer
Service
Webserver
KAFKA
32. 32
Events for Data Locality
Customer
Updated
Submit
Order
Order
Created
Data is
replicated
Orders
Service
Shipping
Service
Customer
Service
Webserver
KAFKA
54. 54
A KTable is just a stream with infinite
retention
KStream orders = builder.stream(“Orders”);
KStream payments = builder.stream(“Payments”);
KTable customers = builder.table(“Customers”);
orders.join(payments, EmailTuple::new, JoinWindows.of(1*MIN))
.join(customers, (tuple, cust) -> tuple.setCust(cust))
.peek((key, tuple) -> emailer.sendMail(tuple));
Materialize a
table in two
lines of code!
57. 57
Streaming is about
1. Processing data
incrementally
2. Moving data to where
it needs to be
processed (quickly
and efficiently)
On Notification
Data Replication
103. 103
The data dichotomy
Data systems are about exposing data.
Services are about hiding it.
Remember the data dichotomy
104. 104
The Data Dichotomy
We want all the good stuff which comes
with a database.
We don’t want to share that database
with anyone else.
But we do want to share datasets in a
sensible way.
105. 105
• Broadcast events
• Retain them in the log
• Compose streaming functions
• Recasting the event stream into
views when you need to query.
Event Driven Services