SlideShare a Scribd company logo
Ben Stopford, Engineer, Confluent
Ten Principals for Effective
Event-Driven Microservices
Ben Stopford
(Office of the CTO)
@benstopford
• Event Driven Microservices
• The toolset: Kafka, KStreams,
Connect
• 10 Principals for Streaming
Services
What we’ll cover
Microservices
in the Kafka
Ecosystem
GUI
UI
Service
Orders
Service
Returns
Service
Fulfilment
Service
Payment
Service
Stock
Service
Microservices
So why
Services?
The Monolith
Can we do reuse, encapsulation?
The Monolith
What happens when we grow?
Companies are
inevitably a collection
of applicationsThey must work together to some degree
Inverse Conway Maneuver
The 'Inverse Conway Maneuver' recommends evolving your
team and organizational structure to promote your desired
architecture.
Org Structure
Software Architecture
Eschew shared, mutable
state
Service based approaches
separate state
But state must inevitably be
shared between services
Use a toolkit that
embraces
decentralisation
10 Principals for Effective Event-Driven Microservices with Apache Kafka
Some simple patterns of
distributed systems
Request /
Response
When do we need
Request Response?
Looking things up
What is in my shopping basket?
Event Driven
Async / Fire and Forget / Brokered
Businesses are often
modeled as a sequence
events.
Add to
cart Buy
Make
Payment
Update
Stock
Email
Conf
Package
Item
Dispatch
Fraud
When do we need
Event Driven?
SOA /
Microservices
Message Broker
Event Based Request/Response
Hybrids
Event-
Based
Request/
Response
Request
ResponseBuy
Items
Order
Service
Stock
Service
Ful-
filment
Service
Fraud
Det-
ection
Mmm…
New IPad
REST etc
UI
Service
Event Driven
Buy
Items
Order
Service
Stock
Service
Ful-
filment
Service
Fraud
Det-
ection
Message Broker
Mmm…
New IPad
UI
Service
Hybrid
ApproachesBuy
Items
Order
Service
Stock
Service
Ful-
filment
Service
Fraud
Det-
ection
Message Broker
Mmm…
New IPad
REST
UI
Service
As software engineers
we are inevitably
affected by the tools we
surround ourselves with.
Languages, frameworks,
even processes all act to
shape the software we
build.
GUI
UI
Service
Orders
Service
Returns
Service
Fulfilment
Service
Payment
Service
Stock
Service
The tools we choose have a big
effect on our architecture
GUI
UI
Service
Orders
Service
Returns
Service
Fulfilment
Service
Payment
Service
Stock
Service
Event Driven Request Response
Kafka is well suited to
Event Driven
Architectures
It will lead you down that path
The Tool Set
a Distributed Log
What is a Distributed
Log?
Shard on the way in
Producing
Services
Kafka
Consuming
Services
Each shard is a queue
Producing
Services
Kafka
Consuming
Services
Consumers share load
Producing
Services
Kafka
Consuming
Services
Reduces to a globally ordered
queue
Load Balanced
Services
Fault Tolerant
Services
Build ‘Always On’ Services
Rely on Fault
Tolerant Broker
Services can “Rewind &
Replay” the log
Rewind & Replay
Compacted Log
(retains only latest version)
Version 3
Version 2
Version 1
Version 2
Version 1
Version 5
Version 4
Version 3
Version 2
Version 1
A database engine for
data-in-flight
Max(price)
From orders
where ccy=‘GBP’
over 1 day window
emitting every second
Continuously Running
Queries
What is stream processing
engine?
Data
Index
Query
Engine
Query
Engine
vs
Database
Finite source
Stream Processor
Infinite source
Windowing
For unordered or unpredictable streams
Sliding
Fixed
(tumbling)
Features: similar to
database query engine
JoinFilter
Aggr-
egate
View
Window
Stateful Stream
Processing
stream
Compacted
stream
Join
Stream Data
Stream-Tabular
Data
Windowed
Stream
Locally Cached
Table
(disk resident)
KafkaKafka Streams
Useful for Enrichment
stream
Compacted
stream
Join
Orders
Customers
KafkaKafka Streams
Scales Out
Embeddable
Orders Service
Kafka
Orders Service
Orders Service
Kafka Connect
View Replication
Sometimes you need
to physically move
data
Replicate it, so both
copies are identical
Iterate via
regeneration
Kafka Connect
Kafka
Connect
Kafka
Connect
Kafka
So…
Service Backbone
Scalable, Fault Tolerant, Concurrent, Strongly Ordered, Stateful
Embeddable tool for data
manipulation
Adapt data streams
(transformation, stream
maintenance, analytic function)
Replicate Data Sources Exactly
Create Regenerable, Streaming
Views
How do we actually
do this?
10 (opinionated) principals for Streaming
Services
1. Don’t use Kafka for
shopping carts!
(OK, you can, but use sparingly)
Shopping
Cart
UI
Service
Broker/durability/broadcast add
little to request response
Do use Kafka for event
driven archtectures.
Think “business events”. An order was created,
a payment was received, a trade was booked
etc. Pub/Sub.
GUI
UI
Service
Orders
Service
Returns
Service
Fulfilment
Service
Payment
Service
Stock
Service
2. Pick Topics with
Business Significance
Orders Payments
Returns Invoices
Give your messages meaningful
IDs and version them
rdersService1-Order-1234-
Should relate to
the real world
Should be
Versioned
(if mutable)
Include the service
name
Note the key used for sharding in Kafka may not be this key
3. Decouple publishers from
subscribers
GUI
UI
Service
Orders
Service
Returns
Service
Fulfilment
Service
Payment
Service
Stock
Service
Add Request/Response
only where needed
GUI
UI
Service
Orders
Service
Returns
Service
Fulfilment
Service
Payment
Service
Stock
Service
REST
4. Use the log to
regenerate state
Avoid journaling incoming events
Event Source side effects
• Use offsets to tie these
back to the stream
• Store in:
• Kafka
• Kstreams state store
• Other DB
5. Apply the Single
Writer Principal
• Change at source (by
calling that service)
• Let the change
propagate back
• Keep local copies read
only.
GUI
UI
Service
Orders
Service
Returns
Service
Fulfilment
Service
Payment
Service
Stock
Service
(1) Change
Orders at source
(2) Let the change propagate through
6. Leverage keeping
datasets inside the
broker
customer country
supplier
ex-
rates
Leverage keeping only
the latest version (table
view)
Version 3
Version 2
Version 1
Version 2
Version 1
Version 5
Version 4
Version 3
Version 2
Version 1
Join & Process on the
fly
stream
Compacted
stream
Join
Orders
Customers
KafkaKafka Streams
7. Prefer stream processing
over maintaining historic
views
UI
Service
Orders
Service
Returns
Service
Fulfilment
Service
Payment
Service
Stock
Service
Orders
Historic
“copies”
diverge
Join & Process on the
fly
stream
Compacted
stream
Join
Orders
Customers
KafkaKafka Streams
8. Sometimes you
need historic views.
=> Replicate & Keep Read Only
Replicate
Kafka
Connect
Kafka
Connect
Kafka
Keep me
Read Only
Iterate
Polyglotic
Persistence
9. Use Schemas
(especially if data is retained)
Schemaless data
doesn’t age well
Confluent Schema
Registry can help
Orders
Service
Schema
Registry
Email
Service
Avro
10. Consider “Stream
Management” Services
Stream
Management
Kafka
• Retaining data => Admin tasks
• Similar to the role of a DBA
• Data Migration
• Repartitioning
• Latest/versioned
• Environment Management
• CQRS
KStreams is a good
toolset for this
Stream Management
KStrea
ms
Latest
Stream
Version
ed
Stream
So…1. Don’t use Kafka for shopping carts!
2. Pick Topics with Business Significance
3. Decouple publishers from subscribers
4. Use the log to regenerate state
5. Apply the Single Writer Principal
6. Leverage keeping datasets inside the broker
7. Prefer stream processing over maintaining
historic views
8. Sometimes you need historic views. => Replicate
Read Only
9. Use Schemas
10. Consider “Stream Management” Services
Microservices push us away
from shared, mutable state
But state needs to be
communicated
In an increasingly data-heavy world
we need tools to do this efficiently
…and in real time.
We need a data-centric
toolset to do this
All Your Data
Immutable
Streams
Event
Driven
Services
Stream
Management
Services
Legacy
CDC
View
Replication
Polyglotic
Persistence
tables streams
Streaming
Services
Keep it simple,
Keep it moving
@benstopford
Thanks!

More Related Content

PDF
Building Event Driven Services with Stateful Streams
PPTX
10 Principals for Effective Event Driven Microservices
PDF
Event Driven Services Part 2: Building Event-Driven Services with Apache Kafka
PDF
Building Event Driven Services with Kafka Streams
PDF
Devoxx London 2017 - Rethinking Services With Stateful Streams
PDF
Building Event Driven Services with Apache Kafka and Kafka Streams - Devoxx B...
PDF
The Future of Streaming: Global Apps, Event Stores and Serverless
PDF
NDC London 2017 - The Data Dichotomy- Rethinking Data and Services with Streams
Building Event Driven Services with Stateful Streams
10 Principals for Effective Event Driven Microservices
Event Driven Services Part 2: Building Event-Driven Services with Apache Kafka
Building Event Driven Services with Kafka Streams
Devoxx London 2017 - Rethinking Services With Stateful Streams
Building Event Driven Services with Apache Kafka and Kafka Streams - Devoxx B...
The Future of Streaming: Global Apps, Event Stores and Serverless
NDC London 2017 - The Data Dichotomy- Rethinking Data and Services with Streams

What's hot (20)

PDF
Putting the Micro into Microservices with Stateful Stream Processing
PDF
The Data Dichotomy- Rethinking the Way We Treat Data and Services
PDF
APAC ksqlDB Workshop
PDF
A Global Source of Truth for the Microservices Generation
PDF
Kafka Summit NYC 2017 - The Data Dichotomy: Rethinking Data and Services with...
PDF
Neha Narkhede | Kafka Summit London 2019 Keynote | Event Streaming: Our Cloud...
PPTX
Jun Rao, Confluent | Kafka Summit SF 2019 Keynote ft. Chris Kasten, Walmart Labs
PPTX
Jay Kreps, Confluent | Kafka Summit SF 2019 Keynote ft. Dev Tagare, Lyft + Pr...
PDF
Jay Kreps | Kafka Summit NYC 2019 Keynote (Events Everywhere) | CEO, Confluent
PDF
Building event-driven Microservices with Kafka Ecosystem
PDF
Concepts and Patterns for Streaming Services with Kafka
PPTX
Microservices in the Apache Kafka Ecosystem
PDF
Now You See Me, Now You Compute: Building Event-Driven Architectures with Apa...
PDF
Event Streaming CTO Roundtable for Cloud-native Kafka Architectures
PDF
Etl, esb, mq? no! es Apache Kafka®
PDF
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
PDF
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
PDF
Building Event-Driven Services with Apache Kafka
PDF
Simplified Hybrid Cloud Migration with Confluent and Google Cloud
PDF
Kafka Summit SF 2017 - From Scaling Nightmare to Stream Dream : Real-time Str...
Putting the Micro into Microservices with Stateful Stream Processing
The Data Dichotomy- Rethinking the Way We Treat Data and Services
APAC ksqlDB Workshop
A Global Source of Truth for the Microservices Generation
Kafka Summit NYC 2017 - The Data Dichotomy: Rethinking Data and Services with...
Neha Narkhede | Kafka Summit London 2019 Keynote | Event Streaming: Our Cloud...
Jun Rao, Confluent | Kafka Summit SF 2019 Keynote ft. Chris Kasten, Walmart Labs
Jay Kreps, Confluent | Kafka Summit SF 2019 Keynote ft. Dev Tagare, Lyft + Pr...
Jay Kreps | Kafka Summit NYC 2019 Keynote (Events Everywhere) | CEO, Confluent
Building event-driven Microservices with Kafka Ecosystem
Concepts and Patterns for Streaming Services with Kafka
Microservices in the Apache Kafka Ecosystem
Now You See Me, Now You Compute: Building Event-Driven Architectures with Apa...
Event Streaming CTO Roundtable for Cloud-native Kafka Architectures
Etl, esb, mq? no! es Apache Kafka®
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Building Event-Driven Services with Apache Kafka
Simplified Hybrid Cloud Migration with Confluent and Google Cloud
Kafka Summit SF 2017 - From Scaling Nightmare to Stream Dream : Real-time Str...
Ad

Similar to 10 Principals for Effective Event-Driven Microservices with Apache Kafka (20)

PDF
JAX London Slides
PDF
Building Event Driven (Micro)services with Apache Kafka
PDF
Microservices with Kafka Ecosystem
PDF
Microservices with Kafka Ecosystem
PDF
Building event-driven (Micro)Services with Apache Kafka
PDF
Building event-driven (Micro)Services with Apache Kafka
PDF
Leveraging Microservice Architectures & Event-Driven Systems for Global APIs
PDF
Microservices for a Streaming World
PDF
Building Event-Driven (Micro)Services with Apache Kafka
PDF
Event Driven Services Part 1: The Data Dichotomy
PDF
Event Driven Services Part 3: Putting the Micro into Microservices with State...
PDF
Building event-driven (Micro)Services with Apache Kafka Ecosystem
PDF
Strata Software Architecture NY: The Data Dichotomy
PDF
Message Driven and Event Sourcing
PDF
Microservices, Events, and Breaking the Data Monolith with Kafka
PDF
Event Driven Microservices
PPTX
Bridge Your Kafka Streams to Azure Webinar
PDF
Battle-tested event-driven patterns for your microservices architecture - Sca...
PPTX
Beyond Microservices: Streams, State and Scalability
PPTX
Evolutionary Systems - Kafka Microservices
JAX London Slides
Building Event Driven (Micro)services with Apache Kafka
Microservices with Kafka Ecosystem
Microservices with Kafka Ecosystem
Building event-driven (Micro)Services with Apache Kafka
Building event-driven (Micro)Services with Apache Kafka
Leveraging Microservice Architectures & Event-Driven Systems for Global APIs
Microservices for a Streaming World
Building Event-Driven (Micro)Services with Apache Kafka
Event Driven Services Part 1: The Data Dichotomy
Event Driven Services Part 3: Putting the Micro into Microservices with State...
Building event-driven (Micro)Services with Apache Kafka Ecosystem
Strata Software Architecture NY: The Data Dichotomy
Message Driven and Event Sourcing
Microservices, Events, and Breaking the Data Monolith with Kafka
Event Driven Microservices
Bridge Your Kafka Streams to Azure Webinar
Battle-tested event-driven patterns for your microservices architecture - Sca...
Beyond Microservices: Streams, State and Scalability
Evolutionary Systems - Kafka Microservices
Ad

More from Ben Stopford (16)

PDF
The Power of the Log
PDF
Streaming, Database & Distributed Systems Bridging the Divide
PDF
Data Pipelines with Apache Kafka
PDF
A little bit of clojure
PPTX
Big iron 2 (published)
PDF
The return of big iron?
PDF
Big Data & the Enterprise
PDF
Where Does Big Data Meet Big Database - QCon 2012
PPTX
Advanced databases ben stopford
PDF
Coherence Implementation Patterns - Sig Nov 2011
PDF
A Paradigm Shift: The Increasing Dominance of Memory-Oriented Solutions for H...
PDF
Balancing Replication and Partitioning in a Distributed Java Database
PDF
Test-Oriented Languages: Is it time for a new era?
PDF
Ideas for Distributing Skills Across a Continental Divide
PDF
Data Grids with Oracle Coherence
PPT
Architecting for Change: An Agile Approach
The Power of the Log
Streaming, Database & Distributed Systems Bridging the Divide
Data Pipelines with Apache Kafka
A little bit of clojure
Big iron 2 (published)
The return of big iron?
Big Data & the Enterprise
Where Does Big Data Meet Big Database - QCon 2012
Advanced databases ben stopford
Coherence Implementation Patterns - Sig Nov 2011
A Paradigm Shift: The Increasing Dominance of Memory-Oriented Solutions for H...
Balancing Replication and Partitioning in a Distributed Java Database
Test-Oriented Languages: Is it time for a new era?
Ideas for Distributing Skills Across a Continental Divide
Data Grids with Oracle Coherence
Architecting for Change: An Agile Approach

Recently uploaded (20)

PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Approach and Philosophy of On baking technology
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Electronic commerce courselecture one. Pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Machine Learning_overview_presentation.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
MIND Revenue Release Quarter 2 2025 Press Release
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Unlocking AI with Model Context Protocol (MCP)
Building Integrated photovoltaic BIPV_UPV.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Approach and Philosophy of On baking technology
SOPHOS-XG Firewall Administrator PPT.pptx
Assigned Numbers - 2025 - Bluetooth® Document
Electronic commerce courselecture one. Pdf
Spectral efficient network and resource selection model in 5G networks
Group 1 Presentation -Planning and Decision Making .pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Spectroscopy.pptx food analysis technology
Digital-Transformation-Roadmap-for-Companies.pptx
Machine Learning_overview_presentation.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf

10 Principals for Effective Event-Driven Microservices with Apache Kafka

Editor's Notes

  • #4: Today we’re going to talk about two fields which sit somewhat apart. Stream Processing & Business Systems Services encourage us to share responsibilities. To rely on others. To collaborate and evolve a business’s view of the world over time. A world that is inherently decentralised. Inherently spread across many interconnected systems. Spreading many disparate subsets of our business’s state. Yet our approach rarely reflects this. We tend to think in centralised ways, we accumulate data. We protect it. We control it. We hoard it. But it does not need to be this way.
  • #6: Today we’re going to talk about two fields which sit somewhat apart. Stream Processing & Business Systems Services encourage us to share responsibilities. To rely on others. To collaborate and evolve a business’s view of the world over time. A world that is inherently decentralised. Inherently spread across many interconnected systems. Spreading many disparate subsets of our business’s state. Yet our approach rarely reflects this. We tend to think in centralised ways, we accumulate data. We protect it. We control it. We hoard it. But it does not need to be this way.
  • #15: My name is Ben Stopford. I work as an engineer on Apache Kafka. In a previous life I did the most centralised thing you could possibly do. I built a single, central database for a large financial institution. This talk is about exploring the exact opposite approach to this problem. It’s about thinking of the world in terms of the evolution and provisioning of state across many systems. It’s about embracing decentralisation. It’s about thinking in streams.