SlideShare a Scribd company logo
Message Reliability in Kafka
Mihai Ghita
Data Engineer
● Delivery guarantees provided by Kafka:
○ At most once
○ At least once
○ Exactly once
● Kafka features:
○ Kafka Idempotent Producer
○ Kafka Transactional Consumer and Producer
Outline
Kafka Producer - Example
Kafka Producer - Example
Kafka Consumer - Example
Kafka Consumer - Example
Delivery
Guarantees
At most once At least once Exactly once
Message Delivery Guarantees
“At Most Once” Guarantee
Kafka Consumer - “At Most Once” Guarantee
Consumer
1 2 3 4 5 6 7 8 9
Batch Size
1.Read records
2.Commit unprocessed
records
Kafka
3. Data
Processing
Kafka Consumer - “At Most Once” Guarantee
Consumer
1 2 3 4 5 6 7 8 9
Batch Size
1.Read records
2.Commit unprocessed
records
Kafka
Consumer
4.Read next
records
5.Commit records
Batch Size
3. Data
Processing
6. Data
Processing
Kafka Producer - “At Most Once” Guarantee
(x,y)
Producer Broker
(x,y)
Producer Broker
1. Send(x,y)
2. Append(x,y)
1. Send(a,b)
2. Append(a,b)
“At Least Once” Guarantee
Kafka Consumer - “At Least Once” Guarantee
Consumer
1 2 3 4 5 6 7 8 9
Batch Size
1.Read records
3.Commit records
Kafka
2. Data
Processing
Kafka Consumer - “At Least Once” Guarantee
Consumer
1 2 3 4 5 6 7 8 9
Batch Size
1.Read records
3.Commit records
Kafka
Consumer
4.Read next records
6.Commit records
Batch Size
2. Data
Processing
5. Data
Processing
Kafka Producer - “At Least Once” Guarantee
(x,y)
Producer Broker
(x,y) (a,b)
Producer (a,b)
Broker
1. Send(x,y) 2. Append(x,y)
3. Ack
1. Send(a,b)
2. Append(a,b)
3. Ack
5. Append(a,b)
4. Resend(a,b)
6. Ack
“Exactly Once” Guarantee
Idempotent Producer
Acknowledgement failure leads to message duplication
(x,y)
Producer Broker
(x,y) (a,b)
Producer (a,b)
Broker
1. Send(x,y) 2. Append(x,y)
3. Ack
1. Send(a,b)
2. Append(a,b)
3. Ack
5. Append(a,b)
4. Resend(a,b)
6. Ack
The idempotent producer will eliminate message duplication from producer side
(x,y)
Seq = 0
PID = 100
Producer Broker
1. Send(x,y)
Seq = 0
PID = 100
2. Append(x,y)
Seq = 0
PID = 100
3. Ack
(x,y)
Seq = 0
PID = 100
Producer Broker
4. Send(a,b)
Seq = 1
PID = 100
2. Append(a,b)
Seq = 1
PID = 100
3. Ack
(a,b)
Seq = 1
PID = 100
5. Ack-Duplicate
1. Send(a,b)
Seq = 1
PID = 100
Kafka Transactions
Producer
Topic A, Partition 0
Topic B, Partition 0
Topic B, Partition 1
Transactional Producer
m1 m5
m3 m4 m6
m2
Producer
Topic A, Partition 0
Topic B, Partition 0
Topic B, Partition 1
Transactional Producer
Transactional Producer
m1 m5 C
m3 m4 m6 C
m2 C
Producer
Topic A, Partition 0
Topic B, Partition 0
Topic B, Partition 1
atomic commit
m1 m5 A
m3 m4 m6 A
m2 A
Producer
Topic A, Partition 0
Topic B, Partition 0
Topic B, Partition 1
atomic abort
Transactional Producer
m1 m5 C
m3 m4 m6 C
m2 C
Consumer
Topic A, Partition 0
Topic B, Partition 0
Topic B, Partition 1
read committed
Transactional Consumer
m11 m12 C
m3 A m8 C
A m2 m9 C
Consumer
Topic A, Partition 0
Topic B, Partition 0
Topic B, Partition 1
read committed
Transactional Consumer
Why are the Transactions Important?
Read
Write
Process
Input
Output
Write all results
Mark all messages as consumed
Write to the output topic
Write offsets to the commit topic
Why are the Transactions Important?
All or nothing!
End-to-End Exactly-Once
Kafka Transactions - Demo
● Delivery guarantees provided by Kafka:
○ At most once
○ At least once
○ Exactly once
● Depending on your needs, choose the right delivery guarantee
Putting it all Together
Message reliability in Kafka
Kafka Transactional - Internal Implementation
Kafka Consumer - Internal Implementation

More Related Content

PDF
Message reliability in kafka
PPTX
Confidentiality as a service –usable security for the cloud
PDF
Deswik Software Suite v5.0: Pseudoflow pit optimization algorithm
PPTX
Apache kafka part 2
PDF
Eclipse Modeling Guided Tour - Acceleo Query Language (AQL)
PDF
201801 CSE240 Lecture 15
PDF
Downsampling your data October 2017
PDF
RedisGears
Message reliability in kafka
Confidentiality as a service –usable security for the cloud
Deswik Software Suite v5.0: Pseudoflow pit optimization algorithm
Apache kafka part 2
Eclipse Modeling Guided Tour - Acceleo Query Language (AQL)
201801 CSE240 Lecture 15
Downsampling your data October 2017
RedisGears

What's hot (6)

PDF
RedisGears: Meir Shpilraien
PPT
lecture 6
PDF
Bcn open stack meet up - july 2014
PDF
No More, No Less: A Formal Model for Serverless Computing
PDF
Functional Programming with JavaScript
PDF
How to Build a Telegraf Plugin by Noah Crowley
RedisGears: Meir Shpilraien
lecture 6
Bcn open stack meet up - july 2014
No More, No Less: A Formal Model for Serverless Computing
Functional Programming with JavaScript
How to Build a Telegraf Plugin by Noah Crowley
Ad

Similar to Message reliability in Kafka (20)

PPTX
Exactly Once Delivery - Natan Silnitsky
PPTX
Kafka101
PPTX
Kafka 101
PDF
Exactly once delivery is a harsh mistress - DevOps Days TLV
PDF
Exactly Once Delivery is a Harsh Mistress - Natan Silnitsky
PDF
Kafka Overview
PDF
Exactly Once Delivery with Kafka - JOTB2020 Mini Session
PPTX
Apache Kafka - Messaging System Overview
PDF
Apache Kafka: New Features That You Might Not Know About
PDF
Handle Large Messages In Apache Kafka
PDF
Kafka - Messaging System
PDF
Reliability Guarantees for Apache Kafka
PDF
Grokking TechTalk #24: Kafka's principles and protocols
PPTX
Apache kafka
PPTX
Kafka tutorial
PPTX
When it Absolutely, Positively, Has to be There: Reliability Guarantees in Ka...
PDF
Exactly Once Delivery with Kafka - Kafka Tel-Aviv Meetup
PPTX
Kafka overview v0.1
PDF
apachekafka-160907180205.pdf
PPTX
Apache kafka
Exactly Once Delivery - Natan Silnitsky
Kafka101
Kafka 101
Exactly once delivery is a harsh mistress - DevOps Days TLV
Exactly Once Delivery is a Harsh Mistress - Natan Silnitsky
Kafka Overview
Exactly Once Delivery with Kafka - JOTB2020 Mini Session
Apache Kafka - Messaging System Overview
Apache Kafka: New Features That You Might Not Know About
Handle Large Messages In Apache Kafka
Kafka - Messaging System
Reliability Guarantees for Apache Kafka
Grokking TechTalk #24: Kafka's principles and protocols
Apache kafka
Kafka tutorial
When it Absolutely, Positively, Has to be There: Reliability Guarantees in Ka...
Exactly Once Delivery with Kafka - Kafka Tel-Aviv Meetup
Kafka overview v0.1
apachekafka-160907180205.pdf
Apache kafka
Ad

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Spectroscopy.pptx food analysis technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
20250228 LYD VKU AI Blended-Learning.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Dropbox Q2 2025 Financial Results & Investor Presentation
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Network Security Unit 5.pdf for BCA BBA.
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Per capita expenditure prediction using model stacking based on satellite ima...
Programs and apps: productivity, graphics, security and other tools
MIND Revenue Release Quarter 2 2025 Press Release
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
Reach Out and Touch Someone: Haptics and Empathic Computing
Review of recent advances in non-invasive hemoglobin estimation
Advanced methodologies resolving dimensionality complications for autism neur...
Spectral efficient network and resource selection model in 5G networks
Spectroscopy.pptx food analysis technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Electronic commerce courselecture one. Pdf
Encapsulation_ Review paper, used for researhc scholars

Message reliability in Kafka

  • 1. Message Reliability in Kafka Mihai Ghita Data Engineer
  • 2. ● Delivery guarantees provided by Kafka: ○ At most once ○ At least once ○ Exactly once ● Kafka features: ○ Kafka Idempotent Producer ○ Kafka Transactional Consumer and Producer Outline
  • 7. Delivery Guarantees At most once At least once Exactly once Message Delivery Guarantees
  • 8. “At Most Once” Guarantee
  • 9. Kafka Consumer - “At Most Once” Guarantee Consumer 1 2 3 4 5 6 7 8 9 Batch Size 1.Read records 2.Commit unprocessed records Kafka 3. Data Processing
  • 10. Kafka Consumer - “At Most Once” Guarantee Consumer 1 2 3 4 5 6 7 8 9 Batch Size 1.Read records 2.Commit unprocessed records Kafka Consumer 4.Read next records 5.Commit records Batch Size 3. Data Processing 6. Data Processing
  • 11. Kafka Producer - “At Most Once” Guarantee (x,y) Producer Broker (x,y) Producer Broker 1. Send(x,y) 2. Append(x,y) 1. Send(a,b) 2. Append(a,b)
  • 12. “At Least Once” Guarantee
  • 13. Kafka Consumer - “At Least Once” Guarantee Consumer 1 2 3 4 5 6 7 8 9 Batch Size 1.Read records 3.Commit records Kafka 2. Data Processing
  • 14. Kafka Consumer - “At Least Once” Guarantee Consumer 1 2 3 4 5 6 7 8 9 Batch Size 1.Read records 3.Commit records Kafka Consumer 4.Read next records 6.Commit records Batch Size 2. Data Processing 5. Data Processing
  • 15. Kafka Producer - “At Least Once” Guarantee (x,y) Producer Broker (x,y) (a,b) Producer (a,b) Broker 1. Send(x,y) 2. Append(x,y) 3. Ack 1. Send(a,b) 2. Append(a,b) 3. Ack 5. Append(a,b) 4. Resend(a,b) 6. Ack
  • 18. Acknowledgement failure leads to message duplication (x,y) Producer Broker (x,y) (a,b) Producer (a,b) Broker 1. Send(x,y) 2. Append(x,y) 3. Ack 1. Send(a,b) 2. Append(a,b) 3. Ack 5. Append(a,b) 4. Resend(a,b) 6. Ack
  • 19. The idempotent producer will eliminate message duplication from producer side (x,y) Seq = 0 PID = 100 Producer Broker 1. Send(x,y) Seq = 0 PID = 100 2. Append(x,y) Seq = 0 PID = 100 3. Ack (x,y) Seq = 0 PID = 100 Producer Broker 4. Send(a,b) Seq = 1 PID = 100 2. Append(a,b) Seq = 1 PID = 100 3. Ack (a,b) Seq = 1 PID = 100 5. Ack-Duplicate 1. Send(a,b) Seq = 1 PID = 100
  • 21. Producer Topic A, Partition 0 Topic B, Partition 0 Topic B, Partition 1 Transactional Producer
  • 22. m1 m5 m3 m4 m6 m2 Producer Topic A, Partition 0 Topic B, Partition 0 Topic B, Partition 1 Transactional Producer
  • 23. Transactional Producer m1 m5 C m3 m4 m6 C m2 C Producer Topic A, Partition 0 Topic B, Partition 0 Topic B, Partition 1 atomic commit
  • 24. m1 m5 A m3 m4 m6 A m2 A Producer Topic A, Partition 0 Topic B, Partition 0 Topic B, Partition 1 atomic abort Transactional Producer
  • 25. m1 m5 C m3 m4 m6 C m2 C Consumer Topic A, Partition 0 Topic B, Partition 0 Topic B, Partition 1 read committed Transactional Consumer
  • 26. m11 m12 C m3 A m8 C A m2 m9 C Consumer Topic A, Partition 0 Topic B, Partition 0 Topic B, Partition 1 read committed Transactional Consumer
  • 27. Why are the Transactions Important? Read Write Process Input Output
  • 28. Write all results Mark all messages as consumed Write to the output topic Write offsets to the commit topic Why are the Transactions Important? All or nothing!
  • 31. ● Delivery guarantees provided by Kafka: ○ At most once ○ At least once ○ Exactly once ● Depending on your needs, choose the right delivery guarantee Putting it all Together
  • 33. Kafka Transactional - Internal Implementation
  • 34. Kafka Consumer - Internal Implementation