SlideShare a Scribd company logo
1 of 34
Download to read offline
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
Kafka Transactional - Internal Implementation
Kafka Consumer - Internal Implementation

More Related Content

What's hot

RedisGears: Meir Shpilraien
RedisGears: Meir ShpilraienRedisGears: Meir Shpilraien
RedisGears: Meir ShpilraienRedis Labs
 
lecture 6
lecture 6lecture 6
lecture 6sajinsc
 
Bcn open stack meet up - july 2014
Bcn open stack meet up - july 2014Bcn open stack meet up - july 2014
Bcn open stack meet up - july 2014Jaume Devesa Gomez
 
No More, No Less: A Formal Model for Serverless Computing
No More, No Less: A Formal Model for Serverless ComputingNo More, No Less: A Formal Model for Serverless Computing
No More, No Less: A Formal Model for Serverless ComputingMarco Peressotti
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScriptMark Shelton
 
How to Build a Telegraf Plugin by Noah Crowley
How to Build a Telegraf Plugin by Noah CrowleyHow to Build a Telegraf Plugin by Noah Crowley
How to Build a Telegraf Plugin by Noah CrowleyInfluxData
 

What's hot (6)

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

Similar to Message reliability in Kafka

Introducing Exactly Once Semantics in Apache Kafka with Matthias J. Sax
Introducing Exactly Once Semantics in Apache Kafka with Matthias J. SaxIntroducing Exactly Once Semantics in Apache Kafka with Matthias J. Sax
Introducing Exactly Once Semantics in Apache Kafka with Matthias J. SaxDatabricks
 
TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)Erhwen Kuo
 
Producer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaProducer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaJiangjie Qin
 
Transaction Support in Pulsar 2.5.0
Transaction Support in Pulsar 2.5.0Transaction Support in Pulsar 2.5.0
Transaction Support in Pulsar 2.5.0StreamNative
 
Transaction preview of Apache Pulsar
Transaction preview of Apache PulsarTransaction preview of Apache Pulsar
Transaction preview of Apache PulsarStreamNative
 
Multi cluster, multitenant and hierarchical kafka messaging service slideshare
Multi cluster, multitenant and hierarchical kafka messaging service   slideshareMulti cluster, multitenant and hierarchical kafka messaging service   slideshare
Multi cluster, multitenant and hierarchical kafka messaging service slideshareAllen (Xiaozhong) Wang
 
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...HostedbyConfluent
 
Kafka Summit SF 2017 - MultiCluster, MultiTenant and Hierarchical Kafka Messa...
Kafka Summit SF 2017 - MultiCluster, MultiTenant and Hierarchical Kafka Messa...Kafka Summit SF 2017 - MultiCluster, MultiTenant and Hierarchical Kafka Messa...
Kafka Summit SF 2017 - MultiCluster, MultiTenant and Hierarchical Kafka Messa...confluent
 
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...Guozhang Wang
 
Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...
Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...
Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...Natan Silnitsky
 
Guaranteed Event Delivery with Kafka and NodeJS | Amitesh Madhur, Nutanix
Guaranteed Event Delivery with Kafka and NodeJS | Amitesh Madhur, NutanixGuaranteed Event Delivery with Kafka and NodeJS | Amitesh Madhur, Nutanix
Guaranteed Event Delivery with Kafka and NodeJS | Amitesh Madhur, NutanixHostedbyConfluent
 
From a Kafkaesque Story to The Promised Land at LivePerson
From a Kafkaesque Story to The Promised Land at LivePersonFrom a Kafkaesque Story to The Promised Land at LivePerson
From a Kafkaesque Story to The Promised Land at LivePersonLivePerson
 
Kafka in Adobe Ad Cloud's Analytics Platform: Building systems with exactly-o...
Kafka in Adobe Ad Cloud's Analytics Platform: Building systems with exactly-o...Kafka in Adobe Ad Cloud's Analytics Platform: Building systems with exactly-o...
Kafka in Adobe Ad Cloud's Analytics Platform: Building systems with exactly-o...Vikram Patankar
 
Apache Kafka in Adobe Ad Cloud's Analytics Platform
Apache Kafka in Adobe Ad Cloud's Analytics PlatformApache Kafka in Adobe Ad Cloud's Analytics Platform
Apache Kafka in Adobe Ad Cloud's Analytics Platformconfluent
 
Apache Kafka Women Who Code Meetup
Apache Kafka Women Who Code MeetupApache Kafka Women Who Code Meetup
Apache Kafka Women Who Code MeetupSnehal Nagmote
 
Locker: distributed consistent locking
Locker: distributed consistent lockingLocker: distributed consistent locking
Locker: distributed consistent lockingKnut Nesheim
 
Fluency - Yet another fluent logger
Fluency - Yet another fluent loggerFluency - Yet another fluent logger
Fluency - Yet another fluent loggerMitsunori Komatsu
 
Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !Guido Schmutz
 

Similar to Message reliability in Kafka (20)

Introducing Exactly Once Semantics in Apache Kafka with Matthias J. Sax
Introducing Exactly Once Semantics in Apache Kafka with Matthias J. SaxIntroducing Exactly Once Semantics in Apache Kafka with Matthias J. Sax
Introducing Exactly Once Semantics in Apache Kafka with Matthias J. Sax
 
TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)
 
Producer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaProducer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache Kafka
 
Transaction Support in Pulsar 2.5.0
Transaction Support in Pulsar 2.5.0Transaction Support in Pulsar 2.5.0
Transaction Support in Pulsar 2.5.0
 
Transaction preview of Apache Pulsar
Transaction preview of Apache PulsarTransaction preview of Apache Pulsar
Transaction preview of Apache Pulsar
 
Multi cluster, multitenant and hierarchical kafka messaging service slideshare
Multi cluster, multitenant and hierarchical kafka messaging service   slideshareMulti cluster, multitenant and hierarchical kafka messaging service   slideshare
Multi cluster, multitenant and hierarchical kafka messaging service slideshare
 
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...
 
Kafka Summit SF 2017 - MultiCluster, MultiTenant and Hierarchical Kafka Messa...
Kafka Summit SF 2017 - MultiCluster, MultiTenant and Hierarchical Kafka Messa...Kafka Summit SF 2017 - MultiCluster, MultiTenant and Hierarchical Kafka Messa...
Kafka Summit SF 2017 - MultiCluster, MultiTenant and Hierarchical Kafka Messa...
 
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...
Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and...
 
Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...
Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...
Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...
 
Guaranteed Event Delivery with Kafka and NodeJS | Amitesh Madhur, Nutanix
Guaranteed Event Delivery with Kafka and NodeJS | Amitesh Madhur, NutanixGuaranteed Event Delivery with Kafka and NodeJS | Amitesh Madhur, Nutanix
Guaranteed Event Delivery with Kafka and NodeJS | Amitesh Madhur, Nutanix
 
From a Kafkaesque Story to The Promised Land at LivePerson
From a Kafkaesque Story to The Promised Land at LivePersonFrom a Kafkaesque Story to The Promised Land at LivePerson
From a Kafkaesque Story to The Promised Land at LivePerson
 
Kafka in Adobe Ad Cloud's Analytics Platform: Building systems with exactly-o...
Kafka in Adobe Ad Cloud's Analytics Platform: Building systems with exactly-o...Kafka in Adobe Ad Cloud's Analytics Platform: Building systems with exactly-o...
Kafka in Adobe Ad Cloud's Analytics Platform: Building systems with exactly-o...
 
Apache Kafka in Adobe Ad Cloud's Analytics Platform
Apache Kafka in Adobe Ad Cloud's Analytics PlatformApache Kafka in Adobe Ad Cloud's Analytics Platform
Apache Kafka in Adobe Ad Cloud's Analytics Platform
 
Apache Kafka Women Who Code Meetup
Apache Kafka Women Who Code MeetupApache Kafka Women Who Code Meetup
Apache Kafka Women Who Code Meetup
 
Locker: distributed consistent locking
Locker: distributed consistent lockingLocker: distributed consistent locking
Locker: distributed consistent locking
 
RabbitMQ in Sprayer
RabbitMQ in SprayerRabbitMQ in Sprayer
RabbitMQ in Sprayer
 
Fluency - Yet another fluent logger
Fluency - Yet another fluent loggerFluency - Yet another fluent logger
Fluency - Yet another fluent logger
 
Kafka Workshop
Kafka WorkshopKafka Workshop
Kafka Workshop
 
Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !
 

Recently uploaded

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

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
  • 32.
  • 33. Kafka Transactional - Internal Implementation
  • 34. Kafka Consumer - Internal Implementation