Professional Documents
Culture Documents
1
There is a book!
http://bit.ly/designing-event-driven-systems
2
Event Driven Architectures
Event Sourcing (DDD)
Stream
Processing
3
Today’s ecosystems get pretty big
4 4
Today’s ecosystems get pretty big
5 5
Event Driven Architectures
Event Sourcing (DDD)
Events
Stream
Processing
6
Notification
Data
replication
7
Notification
Data
replication
8
Streaming Platforms
Kafka Streams /
KSQL
KAFKA
Serving
Layer
(Cassandra etc.)
9
Streaming Pipeline
apps_opened
(a) Apps Opened,
Per App, Per day
opened_per_day
(c) Unstable
Applications unstable_apps
crashed_per_day
Serving
Layer
(Cassandra etc.)
11
Streaming Platforms
Kafka Streams /
KSQL
KAFKA
Serving
Layer
(Cassandra etc.)
12
An event log is a simple idea
Old New
13
Readers have a position all of their own
George
is here Scan
Old New
Fred Sally
is here Scan is here Scan
14
You can rewind and replay, just like Tivo!
Old New
Sally
is here Scan
15
The hard part: Tying it all together!
16
Many ”logs” over many machines
Kafka
Producing Consuming
Services Services
17
Resistant to Failure
Kafka
Producing Consuming
Services Services
18
Streaming Platforms
Kafka Streams /
KSQL
KAFKA
Serving
Layer
(Cassandra etc.)
19
Streaming Example
apps_opened opened_per_day
changelog
20
apps_opened opened_per_day
changelog
21
apps_opened opened_per_day
changelog
22
apps_opened opened_per_day
changelog
23
apps_opened opened_per_day
changelog
24
apps_opened opened_per_day
changelog
25
apps_opened opened_per_day
changelog
26
Streaming is manipulating events in flight,
at scale.
27
Event Driven
Architectures
Stream
Processing
28
Increasingly we build ecosystems
App Ecosystems
29
SOA / Microservices / EDA
Customer
Service
Shipping
Service
30
The Problem is DATA
31
Most services share the same core facts.
Catalog
32
Events have two hats
Notification Data
replication
33
Buying an iPad (with REST/RPC)
Webserver
Submit
Order
shipOrder() getCustomer()
34
Events for Notification Only
Webserver
Submit
Notification Order
Order getCustomer()
Created
Message Broker (Kafka) KAFKA 35
Pluggability
Webserver
Submit
Notification Order
Order getCustomer()
Created
KAFKA 36
Events for Data Locality
Webserver
Submit
Order Data is
replicated
Orders Shipping Customer
Service Service Service
Order Customer
Created Updated
KAFKA 37
Events have two hats
Notification Data
replication
38
Stateless / Stateful Stream Processing
Relates to these hats
39
Stateless Stream Processing
Webserver
Kafka Steams
Submit / KSQL
Notification Order KStreams
Shipping Service
Orders Customer
Service Service
REST/RPC
Order getCustomer()
Created
40
Stateful Stream Processing
Webserver
Data Submit
Order KStreams
KTable
Shipping Service
replication
Orders Customer
Service Service
Order Customer
Created Updated
41
KSQL ~ KStreams
42
Any code you desire
Orders
43
It’s just java
builder.stream(“Orders”)
.join(“Customers”,…)
.transform((key, value) ->
{//Any code your heart desires!}
)
.to(“Shipments”);
44
Streaming can be stateful or stateless
Streaming Engine
46
Event Driven Example
47
1. Use events to decouple and to
collaborate
48
Event Collaboration
Browser
Orders
Notification Service
Webserver
Order
Order Order
Requested
Order
Received Validated Completed
KAFKA
49
2. Use the Single Writer Principal
50
State changes to a topic owned by one service
Browser
Orders
Service
Webserver
Order
Order Order
Requested
Order
Received Validated Completed
KAFKA 51
Local consistency points in the absence
of Global Consistency
REST
Service
T4 T1 T2 Orders
Service
T3
Email
Service
T5
52
3. Convert legacy databases to Events
(with CDC)
53
Make Legacy Datasets Available via the Log
Browser
Orders
Service
Webserver
Order
Order Order
Requested
Order
Received Validated Completed
Products
Connect
KAFKA
54
4. Use Kafka as an Event Store
55
Shared Source of Truth
Browser
Orders
Service
Webserver
Order
Order Order
Requested
Order
Received Validated Completed Reporting
Products
Connect
KAFKA
56
Product Catalogue stored in 3 places
Browser
Orders
Service
Webserver
Reporting view
may be “thinner”
Order
Order Order
Requested
Order
Received Validated Completed Reporting
Products
Connect
KAFKA
57
5. Derive “Materialized Views” instead of
caching
58
Materialize Stock ‘View’ Inside Service
Browser
Orders Data
Service Stock Replication
Webserver
Order
Order
Requested
Order Order
Received Validated Completed
Products Stock
Connect KAFKA
59
Is stateful a good idea?
- Standby Replicas
- Disk Checkpoints
- Compacted topics
- Or just use a database!
60
Database Inside Out Pattern
KAFKA: Retained Event Streams
Payments Products
Orders Customers
62
State stores behave like local databases
Browser State Store
Orders Reserved Stocks
Service Stock
Webserver
Order
Order
Requested
Order Order Reserved Stocks
Received Validated Completed
Products Stock
Connect KAFKA
63
7. Use Transactions to tie All
Interactions Together
64
Transactions
TRANSACTION
Browser
Orders Reserved Stocks
Service Stock
Webserver
Order
Order
Requested
Order Order Reserved Stocks
Received Validated Completed
Products Stock
Connect KAFKA
65
8. Evolve and
Grow through
Streaming
Functions
66
Tiered Contexts
Operations
Finance
KAFKA
Kafka
Front Office
67
Span regions or clouds
68
Handle Disconnectedness
69
So…
70
Optimize for complexity vs optimize for scale
Event Driven
Architectures
Stream
Processing
71
Events provide the key to evolutionary
architectures
Notification Data
replication
72
Spectrum of use cases
Notification
Data
replication
74
Start Simple and Evolve
1. Broadcast events
2. Retain them in the log
3. Evolve the event-stream with
streaming functions
4. Recasting the event stream into
views when you need to query.
75
Find out more
Book: http://bit.ly/designing-event-driven-systems
Software: https://confluent.io/download/
Cloud: https://www.confluent.io/confluent-cloud/
Twitter: @benstopford
76