SlideShare a Scribd company logo
with Python and Apache Kafka
Event-driven Microservices
Dave Klein
dklein@confluent.io twitter.com/daveklein
What do we mean by Event-driven?
https:/
/martinfowler.com/articles/201701-event-driven.html
https:/
/www.youtube.com/watch?v=STKCRSUsyP0
dklein@confluent.io twitter.com/daveklein
What do we mean by Event-driven?
1. Event Noti
fi
cation
2. Event-carried State Transfer
3. Event Sourcing
4. CQRS
https:/
/martinfowler.com/articles/201701-event-driven.html
https:/
/www.youtube.com/watch?v=STKCRSUsyP0
dklein@confluent.io twitter.com/daveklein
Kafka
The Diminutive Guide
dklein@confluent.io twitter.com/daveklein
Noti
fi
cation
Order Placed
Temperature Read
State
{item:123, price: 29.95,
qty: 2}
{temp:21.5, unit: C,
time: 1606949836369}
Event
dklein@confluent.io twitter.com/daveklein
"key": "a1",
"value": {
"eventType": “added-to-cart",
"title": "Kafka Streams in Action”,
"author": "Bill Bejeck",
"price": 44.99
}
dklein@confluent.io twitter.com/daveklein
1 2 3 4 5 6 7 8 9 10 11
Topic (log)
dklein@confluent.io twitter.com/daveklein
1 2 3 4 5 6 7 8 9 10 11
Topic Partitions
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10 11
P1
P2
P3
Brokers and Replication
Broker 1 Broker 2 Broker 3
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10 11
{100}
{200}
{300}
Topic
{101}
{103}
{201} {400}
{301} {401}
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10 11
a1:

{100}
b1:

{200}
c1:

{300}
Topic
a1:

{101}
a1:

{103}
b1:

{201}
d1:

{400}
c1:

{301}
d1:

{401}
1 2 3 4 5 6 7 8 9 10 11
Producer
dklein@confluent.io twitter.com/daveklein
1 2 3 4 5 6 7 8 9 10 11
Producer
dklein@confluent.io twitter.com/daveklein
1 2 3 4 5 6 7
8 9 10 11
Producer
Consumer
dklein@confluent.io twitter.com/daveklein
1 2 3 4 5 6 7 8 9 10 11
Producer
Consumer
dklein@confluent.io twitter.com/daveklein
1 2 3 4 5 6 7 8 9 10 11
Producer
Consumer
dklein@confluent.io twitter.com/daveklein
1 2 3 4 5 6 7 8 9 10 11
Producer
Consumer
Committed Offset: 3
dklein@confluent.io twitter.com/daveklein
Consumer
1 2 3 4 5 6 7 8 9 10 11
Producer
Committed Offset: 3
dklein@confluent.io twitter.com/daveklein
Consumer
1 2 3 4 5 6 7 8 9 10 11
Producer
Committed Offset: 3
dklein@confluent.io twitter.com/daveklein
1 2 3 4 5 6 7 8 9 10 11
Producer
Consumer
Committed Offset: 3
dklein@confluent.io twitter.com/daveklein
Schema Registry
Producer
Consumer
1 2 3 4 5 6 7 8 9 10
dklein@confluent.io twitter.com/daveklein
Consumer Group A
AppInstance01
AppInstance02
AppInstance01
AppInstance02
Consumer Group A
AppInstance03
AppInstance04
Consumer Group A
AppInstance01
AppInstance02
Consumer Group B
OtherApp01
OthereApp02
Using Apache Kafka with Python
kafka-python
KafkaProducer
KafkaConsumer
https:/
/pypi.org/project/kafka-python
dklein@confluent.io twitter.com/daveklein
KafkaAdminClient
Using Apache Kafka with Python
con
fl
uent-kafka-python
Producer
Consumer
AvroProducer
AvroConsumer
AdminClient
https:/
/pypi.org/project/con
fl
uent-kafka
dklein@confluent.io twitter.com/daveklein
Back to Event-driven Microservices
dklein@confluent.io twitter.com/daveklein
Potential Current State
dklein@confluent.io twitter.com/daveklein
dklein@confluent.io twitter.com/daveklein
dklein@confluent.io twitter.com/daveklein
dklein@confluent.io twitter.com/daveklein
How do we get there?
dklein@confluent.io twitter.com/daveklein
Find Events
dklein@confluent.io twitter.com/daveklein
https:/
/videos.con
fl
uent.io/watch/uw9bRczCiYMoHTcGJYtjau
Event Modeling
dklein@confluent.io twitter.com/daveklein
Find Events in Existing Systems
What causes a service to start working?
What info does a service need to do its work?
What action does a service perform?
What information results from that action?
dklein@confluent.io twitter.com/daveklein
Next De
fi
ne Your Topics
One topic per event type?
One topic per domain?
Somewhere in-between?
dklein@confluent.io twitter.com/daveklein
Don’t forget the schema!
A schema for every event type
Schemas will change.
Think about compatibility
dklein@confluent.io twitter.com/daveklein
Demo
Build a random pizza generator
With Python and Kafka
dklein@confluent.io twitter.com/daveklein
Pizza Sauce Cheese Meats Veggies
https:/
/github.com/con
fl
uentinc/demo-scene/tree/master/python-microservices
dklein@confluent.io twitter.com/daveklein
https:/
/cn
fl
.io/book-bundle
https:/
/developer.con
fl
uent.io/learn-kafka
https:/
/developer.con
fl
uent.io/get-started/python
https:/
/github.com/con
fl
uentinc/demo-scene/tree/master/python-microservices
dklein@confluent.io twitter.com/daveklein

More Related Content

More from confluent

Eventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalkEventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalk
confluent
 
Q&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent CloudQ&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent Cloud
confluent
 
Citi TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep DiveCiti TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep Dive
confluent
 
Build real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with ConfluentBuild real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with Confluent
confluent
 
Q&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service MeshQ&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service Mesh
confluent
 
Citi Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka MicroservicesCiti Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka Microservices
confluent
 
Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3
confluent
 
Citi Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging ModernizationCiti Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging Modernization
confluent
 
Citi Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time dataCiti Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time data
confluent
 
Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2
confluent
 
Data In Motion Paris 2023
Data In Motion Paris 2023Data In Motion Paris 2023
Data In Motion Paris 2023
confluent
 
Confluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with SynthesisConfluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with Synthesis
confluent
 
The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023
confluent
 
The Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data StreamsThe Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data Streams
confluent
 
The Journey to Data Mesh with Confluent
The Journey to Data Mesh with ConfluentThe Journey to Data Mesh with Confluent
The Journey to Data Mesh with Confluent
confluent
 
Citi Tech Talk: Monitoring and Performance
Citi Tech Talk: Monitoring and PerformanceCiti Tech Talk: Monitoring and Performance
Citi Tech Talk: Monitoring and Performance
confluent
 
Confluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with ReplyConfluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with Reply
confluent
 
Citi Tech Talk Disaster Recovery Solutions Deep Dive
Citi Tech Talk  Disaster Recovery Solutions Deep DiveCiti Tech Talk  Disaster Recovery Solutions Deep Dive
Citi Tech Talk Disaster Recovery Solutions Deep Dive
confluent
 
Citi Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid CloudCiti Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid Cloud
confluent
 
Partner Tech Talk Q3: Q&A with PS - Migration and Upgrade
Partner Tech Talk Q3: Q&A with PS - Migration and UpgradePartner Tech Talk Q3: Q&A with PS - Migration and Upgrade
Partner Tech Talk Q3: Q&A with PS - Migration and Upgrade
confluent
 

More from confluent (20)

Eventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalkEventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalk
 
Q&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent CloudQ&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent Cloud
 
Citi TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep DiveCiti TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep Dive
 
Build real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with ConfluentBuild real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with Confluent
 
Q&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service MeshQ&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service Mesh
 
Citi Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka MicroservicesCiti Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka Microservices
 
Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3
 
Citi Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging ModernizationCiti Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging Modernization
 
Citi Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time dataCiti Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time data
 
Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2
 
Data In Motion Paris 2023
Data In Motion Paris 2023Data In Motion Paris 2023
Data In Motion Paris 2023
 
Confluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with SynthesisConfluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with Synthesis
 
The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023
 
The Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data StreamsThe Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data Streams
 
The Journey to Data Mesh with Confluent
The Journey to Data Mesh with ConfluentThe Journey to Data Mesh with Confluent
The Journey to Data Mesh with Confluent
 
Citi Tech Talk: Monitoring and Performance
Citi Tech Talk: Monitoring and PerformanceCiti Tech Talk: Monitoring and Performance
Citi Tech Talk: Monitoring and Performance
 
Confluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with ReplyConfluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with Reply
 
Citi Tech Talk Disaster Recovery Solutions Deep Dive
Citi Tech Talk  Disaster Recovery Solutions Deep DiveCiti Tech Talk  Disaster Recovery Solutions Deep Dive
Citi Tech Talk Disaster Recovery Solutions Deep Dive
 
Citi Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid CloudCiti Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid Cloud
 
Partner Tech Talk Q3: Q&A with PS - Migration and Upgrade
Partner Tech Talk Q3: Q&A with PS - Migration and UpgradePartner Tech Talk Q3: Q&A with PS - Migration and Upgrade
Partner Tech Talk Q3: Q&A with PS - Migration and Upgrade
 

Event-Driven Microservices with Python and Apache Kafka®