SlideShare a Scribd company logo
1 of 123
Download to read offline
1
Exactly-Once Made Fast
Boyang Chen: Engineer@Confluent
Guozhang Wang: Engineer@Confluent
2
- Recap: exactly-once semantics (EOS) for Kafka
- What cost are we paying for EOS today
- Closing the gaps: usability and scalability
Overview
3
Back in 2017..
4
5
6
7
8
9
Commit
10
Commit
11
Commit
12
Commit
Atomic
13
The Kafka Approach for Exactly Once
1) Idempotent writes in order within a single topic partition
2) Transactional writes across multiple output topic partitions
3) Guarantee single writer for any input topic partitions
[KIP-98, KIP-129]
14
The Kafka Approach for Exactly Once
1) Idempotent writes in order within a single topic partition
2) Transactional writes across multiple output topic partitions
3) Guarantee single writer for any input topic partitions
[KIP-98, KIP-129]
15
Kafka Transactions
16
17
txn-status: non-exist, partitions: {}
18
txn-status: non-exist, partitions: {}
producer.initTxn();
19
txn-status: empty, partitions: {}
producer.initTxn();
non-exist
20
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
}
} catch (KafkaException e) {
}txn-status: empty, partitions: {}
producer.initTxn();
21
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
} catch (KafkaException e) {
}txn-status: empty, partitions: {}
producer.initTxn();
22
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
} catch (KafkaException e) {
}txn-status: on-going, partitions: {output-0}
producer.initTxn();
non-exist {}
23
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
} catch (KafkaException e) {
}txn-status: on-going, partitions: {output-0}
producer.initTxn();
24
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
} catch (KafkaException e) {
}txn-status: on-going, partitions: {output-0}
producer.initTxn();
25
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
} catch (KafkaException e) {
}txn-status: on-going, partitions: {output-0}
producer.initTxn();
26
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
} catch (KafkaException e) {
}txn-status: on-going, partitions: {output-0}
producer.initTxn();
27
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
} catch (KafkaException e) {
}txn-status: on-going, partitions: {output-0, offset-0}
producer.initTxn();
{output-0}
28
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
producer.commitTxn();
} catch (KafkaException e) {
}txn-status: on-going, partitions: {output-0, offset-0}
producer.initTxn();
29
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
producer.commitTxn();
} catch (KafkaException e) {
}txn-status: prep-commit, partitions: {output-0, offset-0}
producer.initTxn();
on-going
30
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
producer.commitTxn();
} catch (KafkaException e) {
}txn-status: prep-commit, partitions: {output-0, offset-0}
producer.initTxn();
31
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
producer.commitTxn();
} catch (KafkaException e) {
}txn-status: prep-commit, partitions: {output-0, offset-0}
producer.initTxn();
32
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
producer.commitTxn();
} catch (KafkaException e) {
}txn-status: committed, partitions: {output-0, offset-0}
producer.initTxn();
prep-commit
33
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
producer.commitTxn();
} catch (KafkaException e) {
}txn-status: on-going, partitions: {output-0, offset-0}
producer.initTxn();
34
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
producer.commitTxn();
} catch (KafkaException e) {
producer.abortTxn();
}txn-status: on-going, partitions: {output-0, offset-0}
producer.initTxn();
35
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
producer.commitTxn();
} catch (KafkaException e) {
producer.abortTxn();
}txn-status: prep-abort, partitions: {output-0, offset-0}
producer.initTxn();
on-going
36
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
producer.commitTxn();
} catch (KafkaException e) {
producer.abortTxn();
}txn-status: prep-abort, partitions: {output-0, offset-0}
producer.initTxn();
37
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
producer.commitTxn();
} catch (KafkaException e) {
producer.abortTxn();
}txn-status: prep-abort, partitions: {output-0, offset-0}
producer.initTxn();
38
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(..);
producer.commitTxn();
} catch (KafkaException e) {
producer.abortTxn();
}txn-status: aborted, partitions: {output-0, offset-0}
producer.initTxn();
prep-abort
39
The Kafka Approach for Exactly Once:
1) Idempotent writes in order within a single topic partition
2) Transactional writes across multiple output topic partitions
3) Guarantee single writer for any input topic partitions
40
41
42
At a given time, an input partition should only be processed by a single client
43
At a given time, an input partition should only be processed by a single client
Consumer Group
44
At a given time, an input partition should only be processed by a single client
Consumer Group
45
At a given time, an input partition should only be processed by a single client
Consumer Group
46
The “Single Writer” Fencing Problem
47
When Taking Over the Partition:
1) The previous txn must have completed commit or abort so there are no
concurrent transactions.
2) Other clients will be fenced write processing results for those input
partitions, a.k.a we have a “single writer”.
48
Transactional ID: defines single writer scope
1) Configured by the unique producer `transactional.id` property.
2) Enforced fencing by a monotonic epoch for each id.
3) Producer initialization await pending transaction completion.
49
Transaction ID: defines single writer scope
1) Configured by the unique producer `transactional.id` property.
2) Enforced fencing by a monotonic epoch for each id.
3) Producer initialization await pending transaction completion.
50
Transaction ID: defines single writer scope
1) Configured by the unique producer `transactional.id` property.
2) Enforced fencing by a monotonic epoch for each id.
3) Producer initialization await pending transaction completion.
51
Consumer Group
txn.Id = A, epoch = 1
txn.Id = B, epoch = 1
52
Consumer Group
txn.Id = A, epoch = 1
53
Consumer Group
txn.Id = A, epoch = 1
54
Consumer Group
txn.Id = A, epoch = 1
55
Consumer Group
txn.Id = A, epoch = 1
txn.Id = B, initializing...
56
Consumer Group
txn.Id = A, epoch = 1
txn.Id = B, epoch = 2
57
Consumer Group
txn.Id = A, epoch = 1
txn.Id = B, epoch = 2
Num. producer transaction IDs ~= num. input partitions
Producers need to be dynamically created when rebalance
58
EOS Scalability
59
Number of Input
Partitions
Growth of Producers
Number of
Applications
5 10 15 20 25 30
600
500
400
300
200
1
00
60
Number of Input
Partitions
At Least Once
Growth of Producers
Number of
Applications
5 10 15 20 25 30
600
500
400
300
200
1
00
61
Number of Input
Partitions
At Least Once
Growth of Producers
Number of
Applications
5 10 15 20 25 30
600
500
400
300
200
1
00
Exactly Once
62
KIP-447
63
What problems
are KIP-447
solving ?
64
What problems
are KIP-447
solving ?
● Make one producer per process model work
65
What problems
are KIP-447
solving ?
● Make one producer per process model work
● Unblock technical challenges
○ Commit fencing
○ Concurrent transaction
66
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
67
● We are fencing on the transactional producer side,
which assumes a static partition assignment
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
68
● We are fencing on the transactional producer side,
which assumes a static partition assignment
● Consumer group partition assignments are dynamic
in practice
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
69
70
71
72
73
74
75
● We are fencing on the transactional producer side,
which assumes a static partition assignment
● Consumer group partition assignments are dynamic
in practice
● Action: fence zombie producer commit
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
76
● We are fencing on the transactional producer side,
which assumes a static partition assignment
● Consumer group partition assignments are dynamic
in practice
● Action: fence zombie producer commit
○ Different from epoch fencing
○ Utilize consumer group generation ~= epoch
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
77
78
79
80
81
82
83
84
● We are fencing on the transactional producer side,
which assumes a static partition assignment
● Consumer group partition assignments are dynamic
in practice
● Action: fence zombie producer commit
○ Different from epoch fencing
○ Utilize consumer group generation ~= epoch
● Add new APIs
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
85
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(offsets);
producer.commitTxn();
} catch (KafkaException e) {
}txn-status: on-going, partitions: {output, offset}
86
try {
producer.beginTxn();
records = consumer.poll();
for (Record rec <- records) {
// process ..
producer.send(“output”, ..);
}
producer.sendOffsets(offsets,
consumer.groupMetadata());
producer.commitTxn();
} catch (KafkaException e) {
}
txn-status: on-going, partitions: {output, offset}
87
● We are fencing on the transactional producer side,
which assumes a static partition assignment
● Consumer group partition assignments are dynamic
in practice
● Action: fence zombie producer commit
○ Different from epoch fencing
○ Utilize consumer group generation ~= epoch
● Add new APIs
○ Expose group generation through
consumer#groupMetadata()
○ Commit transaction with consumer metadata through
producer#sendOffsetsToTransaction(offsets,
groupMetadata)
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
88
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
89
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
● Only one open transaction allowed for each input
partition
90
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
● Only one open transaction allowed for each input
partition
● Offset commit is the only critical section
91
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
● Only one open transaction allowed for each input
partition
● Offset commit is the only critical section
○ Observed: Pending offsets could be completed later,
causing duplicate processing
92
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
● Only one open transaction allowed for each input
partition
● Offset commit is the only critical section
○ Observed: Pending offsets could be completed later,
causing duplicate processing
○ Observed: consumer always needs to fetch offset after
rebalance
93
What problems
are KIP-447
solving ?
● Commit fencing
● Concurrent Transaction
● Only one open transaction allowed for each input
partition
● Offset commit is the only critical section
○ Observed: Pending offsets could be completed later,
causing duplicate processing
○ Observed: consumer always needs to fetch offset after
rebalance
○ Action: OffsetFetchRequest will back-off until pending
commits are cleared, either by previous transaction
complete or timeout
94
95
96
97
98
99
100
447 Summary
101
447 Summary
● Resolve the semantic mismatch between producer
and consumer
○ Commit Fencing
○ Concurrent Transaction
102
447 Summary
● Resolve the semantic mismatch between producer
and consumer
○ Commit Fencing
○ Concurrent Transaction
● Make the one producer per processing unit possible
103
Number of Input
Partitions
At Least Once
Growth of Producers
Number of
Applications
5 10 15 20 25 30
600
500
400
300
200
1
00
Exactly Once
104
Number of Input
Partitions
At Least Once
Growth of Producers
Number of
Applications
5 10 15 20 25 30
600
500
400
300
200
1
00
Exactly Once
Exactly Once After 447
105
447 Summary
● Resolve the semantic mismatch between producer
and consumer
○ Commit Fencing
○ Concurrent Transaction
● Make the one producer per processing unit possible
● Next we will talk about our scale testing result, and
how to turn on 447 for Kafka Streams, a major EOS
adopter
106
Scale Testing
107
Prove the 447 scalability improvement to
break the limit
- At_least_once
- Exactly_once
- Exactly_once_beta (post KIP-447 EOS)
Scale Testing
108
Scale Testing
109
Scale Testing
● Num.brokers = 3
● Num.input.partitions = 200
● Num.output.partitions = 100
● Test.interval.ms = 4 min
● Num.threads = 3
● Num.records.second = 1000
● Commit.interval.ms = 1 second
● Num.instances = 10, 20, 30...
110
Scale Testing
● Num.brokers = 3
● Num.input.partitions = 200
● Num.output.partitions = 100
● Test.interval.ms = 4 min
● Num.threads = 3
● Num.records.second = 1000
● Commit.interval.ms = 1 second
● Num.instances = 10, 20, 30...
111
Scale Testing
● At_least_once and
exactly_once_beta perform
steadily
● Exactly_once (pre KIP-447)
throughput degrades
significantly around 20-25
applications
112
Opt-in on Kafka Streams
113
Upgrade Procedure
114
Upgrade Procedure
● Rolling bounce brokers to >= Apache Kafka 2.5
115
Upgrade Procedure
● Rolling bounce brokers to >= Apache Kafka 2.5
● Upgrade the stream application binary and keep the
PROCESSING_GUARATNEE setting at "exactly_once". Do the first rolling
bounce, and make sure the group is stable with every instance on 2.6 binary.
116
Upgrade Procedure
● Rolling bounce brokers to >= Apache Kafka 2.5
● Upgrade the stream application binary and keep the
PROCESSING_GUARATNEE setting at "exactly_once". Do the first rolling
bounce, and make sure the group is stable with every instance on 2.6 binary.
● Upgrade the PROCESSING_GUARANTEE setting to "exactly_once_beta" and do
a second rolling bounce to starts using new thread producer for EOS.
117
Conclusion
118
Kafka has an elegant transaction model which has held up well.
119
Kafka has an elegant transaction model which has held up well.
● Address hardness with usability by fixing the
producer/consumer semantic mismatch
120
Kafka has an elegant transaction model which has held up well.
● Address hardness with usability by fixing the
producer/consumer semantic mismatch
● Breakthrough on the scalability
121
Kafka has an elegant transaction model which has held up well.
● Address hardness with usability by fixing the
producer/consumer semantic mismatch
● Breakthrough on the scalability
● How to opt-in new EOS model on Kafka Streams
122
Thank you!
123
- KIP-98 - Exactly Once Delivery and Transactional
Messaging - Apache Kafka
- KIP-447: Producer scalability for exactly once
semantics - Apache Kafka
Resources

More Related Content

What's hot

Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
confluent
 
Kafka Multi-Tenancy - 160 Billion Daily Messages on One Shared Cluster at LINE
Kafka Multi-Tenancy - 160 Billion Daily Messages on One Shared Cluster at LINEKafka Multi-Tenancy - 160 Billion Daily Messages on One Shared Cluster at LINE
Kafka Multi-Tenancy - 160 Billion Daily Messages on One Shared Cluster at LINE
kawamuray
 

What's hot (20)

Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
 
Apache Kafka, and the Rise of Stream Processing
Apache Kafka, and the Rise of Stream ProcessingApache Kafka, and the Rise of Stream Processing
Apache Kafka, and the Rise of Stream Processing
 
So You Want to Write a Connector?
So You Want to Write a Connector? So You Want to Write a Connector?
So You Want to Write a Connector?
 
Getting Started with Confluent Schema Registry
Getting Started with Confluent Schema RegistryGetting Started with Confluent Schema Registry
Getting Started with Confluent Schema Registry
 
Apache Kafka: New Features That You Might Not Know About
Apache Kafka: New Features That You Might Not Know AboutApache Kafka: New Features That You Might Not Know About
Apache Kafka: New Features That You Might Not Know About
 
Actors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesActors or Not: Async Event Architectures
Actors or Not: Async Event Architectures
 
ksqlDB: A Stream-Relational Database System
ksqlDB: A Stream-Relational Database SystemksqlDB: A Stream-Relational Database System
ksqlDB: A Stream-Relational Database System
 
Exactly-once Stream Processing with Kafka Streams
Exactly-once Stream Processing with Kafka StreamsExactly-once Stream Processing with Kafka Streams
Exactly-once Stream Processing with Kafka Streams
 
Building Scalable and Extendable Data Pipeline for Call of Duty Games: Lesson...
Building Scalable and Extendable Data Pipeline for Call of Duty Games: Lesson...Building Scalable and Extendable Data Pipeline for Call of Duty Games: Lesson...
Building Scalable and Extendable Data Pipeline for Call of Duty Games: Lesson...
 
Running Kafka On Kubernetes With Strimzi For Real-Time Streaming Applications
Running Kafka On Kubernetes With Strimzi For Real-Time Streaming ApplicationsRunning Kafka On Kubernetes With Strimzi For Real-Time Streaming Applications
Running Kafka On Kubernetes With Strimzi For Real-Time Streaming Applications
 
What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019
What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019
What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019
 
Real Time Streaming Data with Kafka and TensorFlow (Yong Tang, MobileIron) Ka...
Real Time Streaming Data with Kafka and TensorFlow (Yong Tang, MobileIron) Ka...Real Time Streaming Data with Kafka and TensorFlow (Yong Tang, MobileIron) Ka...
Real Time Streaming Data with Kafka and TensorFlow (Yong Tang, MobileIron) Ka...
 
Exactly-once Data Processing with Kafka Streams - July 27, 2017
Exactly-once Data Processing with Kafka Streams - July 27, 2017Exactly-once Data Processing with Kafka Streams - July 27, 2017
Exactly-once Data Processing with Kafka Streams - July 27, 2017
 
Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...
Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...
Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...
 
KSQL Performance Tuning for Fun and Profit ( Nick Dearden, Confluent) Kafka S...
KSQL Performance Tuning for Fun and Profit ( Nick Dearden, Confluent) Kafka S...KSQL Performance Tuning for Fun and Profit ( Nick Dearden, Confluent) Kafka S...
KSQL Performance Tuning for Fun and Profit ( Nick Dearden, Confluent) Kafka S...
 
Building Out Your Kafka Developer CDC Ecosystem
Building Out Your Kafka Developer CDC  EcosystemBuilding Out Your Kafka Developer CDC  Ecosystem
Building Out Your Kafka Developer CDC Ecosystem
 
KSQL: Streaming SQL for Kafka
KSQL: Streaming SQL for KafkaKSQL: Streaming SQL for Kafka
KSQL: Streaming SQL for Kafka
 
Introduction to Kafka Streams
Introduction to Kafka StreamsIntroduction to Kafka Streams
Introduction to Kafka Streams
 
Kafka Multi-Tenancy - 160 Billion Daily Messages on One Shared Cluster at LINE
Kafka Multi-Tenancy - 160 Billion Daily Messages on One Shared Cluster at LINEKafka Multi-Tenancy - 160 Billion Daily Messages on One Shared Cluster at LINE
Kafka Multi-Tenancy - 160 Billion Daily Messages on One Shared Cluster at LINE
 
Stream Application Development with Apache Kafka
Stream Application Development with Apache KafkaStream Application Development with Apache Kafka
Stream Application Development with Apache Kafka
 

Similar to Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and Scalability (Boyang Chen & Guozhang Wang, Confluent) Kafka Summit 2020

SFBigAnalytics_20190724: Monitor kafka like a Pro
SFBigAnalytics_20190724: Monitor kafka like a ProSFBigAnalytics_20190724: Monitor kafka like a Pro
SFBigAnalytics_20190724: Monitor kafka like a Pro
Chester Chen
 
Crossing Abstraction Barriers When Debugging In Dynamic Languages
Crossing Abstraction Barriers When Debugging In Dynamic LanguagesCrossing Abstraction Barriers When Debugging In Dynamic Languages
Crossing Abstraction Barriers When Debugging In Dynamic Languages
Bastian Kruck
 

Similar to Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and Scalability (Boyang Chen & Guozhang Wang, Confluent) Kafka Summit 2020 (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
 
Producer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaProducer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache Kafka
 
Kostas Kloudas - Extending Flink's Streaming APIs
Kostas Kloudas - Extending Flink's Streaming APIsKostas Kloudas - Extending Flink's Streaming APIs
Kostas Kloudas - Extending Flink's Streaming APIs
 
TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)
 
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
 
blockchain-and-trusted-computing
blockchain-and-trusted-computingblockchain-and-trusted-computing
blockchain-and-trusted-computing
 
SFBigAnalytics_20190724: Monitor kafka like a Pro
SFBigAnalytics_20190724: Monitor kafka like a ProSFBigAnalytics_20190724: Monitor kafka like a Pro
SFBigAnalytics_20190724: Monitor kafka like a Pro
 
Eclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India 2015 - Java bytecode analysis and JITEclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India 2015 - Java bytecode analysis and JIT
 
JVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixJVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, Wix
 
Crossing Abstraction Barriers When Debugging In Dynamic Languages
Crossing Abstraction Barriers When Debugging In Dynamic LanguagesCrossing Abstraction Barriers When Debugging In Dynamic Languages
Crossing Abstraction Barriers When Debugging In Dynamic Languages
 
High Performance Erlang - Pitfalls and Solutions
High Performance Erlang - Pitfalls and SolutionsHigh Performance Erlang - Pitfalls and Solutions
High Performance Erlang - Pitfalls and Solutions
 
Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...
Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...
Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...
 
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyKotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
 
ez-clang C++ REPL for bare-metal embedded devices
ez-clang C++ REPL for bare-metal embedded devicesez-clang C++ REPL for bare-metal embedded devices
ez-clang C++ REPL for bare-metal embedded devices
 
(Open) MPI, Parallel Computing, Life, the Universe, and Everything
(Open) MPI, Parallel Computing, Life, the Universe, and Everything(Open) MPI, Parallel Computing, Life, the Universe, and Everything
(Open) MPI, Parallel Computing, Life, the Universe, and Everything
 
Talk Python To Me: Stream Processing in your favourite Language with Beam on ...
Talk Python To Me: Stream Processing in your favourite Language with Beam on ...Talk Python To Me: Stream Processing in your favourite Language with Beam on ...
Talk Python To Me: Stream Processing in your favourite Language with Beam on ...
 
Onnc intro
Onnc introOnnc intro
Onnc intro
 
Transactions in Action: the Story of Exactly Once in Apache Kafka
Transactions in Action: the Story of Exactly Once in Apache KafkaTransactions in Action: the Story of Exactly Once in Apache Kafka
Transactions in Action: the Story of Exactly Once in Apache Kafka
 
Kenneth Knowles - Apache Beam - A Unified Model for Batch and Streaming Data...
Kenneth Knowles -  Apache Beam - A Unified Model for Batch and Streaming Data...Kenneth Knowles -  Apache Beam - A Unified Model for Batch and Streaming Data...
Kenneth Knowles - Apache Beam - A Unified Model for Batch and Streaming Data...
 
Building a Scalable Real-Time Fleet Management IoT Data Tracker with Kafka St...
Building a Scalable Real-Time Fleet Management IoT Data Tracker with Kafka St...Building a Scalable Real-Time Fleet Management IoT Data Tracker with Kafka St...
Building a Scalable Real-Time Fleet Management IoT Data Tracker with Kafka St...
 

More from HostedbyConfluent

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
HostedbyConfluent
 
Evolution of NRT Data Ingestion Pipeline at Trendyol
Evolution of NRT Data Ingestion Pipeline at TrendyolEvolution of NRT Data Ingestion Pipeline at Trendyol
Evolution of NRT Data Ingestion Pipeline at Trendyol
HostedbyConfluent
 

More from HostedbyConfluent (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Renaming a Kafka Topic | Kafka Summit London
Renaming a Kafka Topic | Kafka Summit LondonRenaming a Kafka Topic | Kafka Summit London
Renaming a Kafka Topic | Kafka Summit London
 
Evolution of NRT Data Ingestion Pipeline at Trendyol
Evolution of NRT Data Ingestion Pipeline at TrendyolEvolution of NRT Data Ingestion Pipeline at Trendyol
Evolution of NRT Data Ingestion Pipeline at Trendyol
 
Ensuring Kafka Service Resilience: A Dive into Health-Checking Techniques
Ensuring Kafka Service Resilience: A Dive into Health-Checking TechniquesEnsuring Kafka Service Resilience: A Dive into Health-Checking Techniques
Ensuring Kafka Service Resilience: A Dive into Health-Checking Techniques
 
Exactly-once Stream Processing with Arroyo and Kafka
Exactly-once Stream Processing with Arroyo and KafkaExactly-once Stream Processing with Arroyo and Kafka
Exactly-once Stream Processing with Arroyo and Kafka
 
Fish Plays Pokemon | Kafka Summit London
Fish Plays Pokemon | Kafka Summit LondonFish Plays Pokemon | Kafka Summit London
Fish Plays Pokemon | Kafka Summit London
 
Tiered Storage 101 | Kafla Summit London
Tiered Storage 101 | Kafla Summit LondonTiered Storage 101 | Kafla Summit London
Tiered Storage 101 | Kafla Summit London
 
Building a Self-Service Stream Processing Portal: How And Why
Building a Self-Service Stream Processing Portal: How And WhyBuilding a Self-Service Stream Processing Portal: How And Why
Building a Self-Service Stream Processing Portal: How And Why
 
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
 
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
 
Navigating Private Network Connectivity Options for Kafka Clusters
Navigating Private Network Connectivity Options for Kafka ClustersNavigating Private Network Connectivity Options for Kafka Clusters
Navigating Private Network Connectivity Options for Kafka Clusters
 
Apache Flink: Building a Company-wide Self-service Streaming Data Platform
Apache Flink: Building a Company-wide Self-service Streaming Data PlatformApache Flink: Building a Company-wide Self-service Streaming Data Platform
Apache Flink: Building a Company-wide Self-service Streaming Data Platform
 
Explaining How Real-Time GenAI Works in a Noisy Pub
Explaining How Real-Time GenAI Works in a Noisy PubExplaining How Real-Time GenAI Works in a Noisy Pub
Explaining How Real-Time GenAI Works in a Noisy Pub
 
TL;DR Kafka Metrics | Kafka Summit London
TL;DR Kafka Metrics | Kafka Summit LondonTL;DR Kafka Metrics | Kafka Summit London
TL;DR Kafka Metrics | Kafka Summit London
 
A Window Into Your Kafka Streams Tasks | KSL
A Window Into Your Kafka Streams Tasks | KSLA Window Into Your Kafka Streams Tasks | KSL
A Window Into Your Kafka Streams Tasks | KSL
 
Mastering Kafka Producer Configs: A Guide to Optimizing Performance
Mastering Kafka Producer Configs: A Guide to Optimizing PerformanceMastering Kafka Producer Configs: A Guide to Optimizing Performance
Mastering Kafka Producer Configs: A Guide to Optimizing Performance
 
Data Contracts Management: Schema Registry and Beyond
Data Contracts Management: Schema Registry and BeyondData Contracts Management: Schema Registry and Beyond
Data Contracts Management: Schema Registry and Beyond
 
Code-First Approach: Crafting Efficient Flink Apps
Code-First Approach: Crafting Efficient Flink AppsCode-First Approach: Crafting Efficient Flink Apps
Code-First Approach: Crafting Efficient Flink Apps
 
Debezium vs. the World: An Overview of the CDC Ecosystem
Debezium vs. the World: An Overview of the CDC EcosystemDebezium vs. the World: An Overview of the CDC Ecosystem
Debezium vs. the World: An Overview of the CDC Ecosystem
 
Beyond Tiered Storage: Serverless Kafka with No Local Disks
Beyond Tiered Storage: Serverless Kafka with No Local DisksBeyond Tiered Storage: Serverless Kafka with No Local Disks
Beyond Tiered Storage: Serverless Kafka with No Local Disks
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
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...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Exactly-Once Made Easy: Transactional Messaging Improvement for Usability and Scalability (Boyang Chen & Guozhang Wang, Confluent) Kafka Summit 2020

  • 1. 1 Exactly-Once Made Fast Boyang Chen: Engineer@Confluent Guozhang Wang: Engineer@Confluent
  • 2. 2 - Recap: exactly-once semantics (EOS) for Kafka - What cost are we paying for EOS today - Closing the gaps: usability and scalability Overview
  • 4. 4
  • 5. 5
  • 6. 6
  • 7. 7
  • 8. 8
  • 13. 13 The Kafka Approach for Exactly Once 1) Idempotent writes in order within a single topic partition 2) Transactional writes across multiple output topic partitions 3) Guarantee single writer for any input topic partitions [KIP-98, KIP-129]
  • 14. 14 The Kafka Approach for Exactly Once 1) Idempotent writes in order within a single topic partition 2) Transactional writes across multiple output topic partitions 3) Guarantee single writer for any input topic partitions [KIP-98, KIP-129]
  • 16. 16
  • 18. 18 txn-status: non-exist, partitions: {} producer.initTxn();
  • 19. 19 txn-status: empty, partitions: {} producer.initTxn(); non-exist
  • 20. 20 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. } } catch (KafkaException e) { }txn-status: empty, partitions: {} producer.initTxn();
  • 21. 21 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } } catch (KafkaException e) { }txn-status: empty, partitions: {} producer.initTxn();
  • 22. 22 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } } catch (KafkaException e) { }txn-status: on-going, partitions: {output-0} producer.initTxn(); non-exist {}
  • 23. 23 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } } catch (KafkaException e) { }txn-status: on-going, partitions: {output-0} producer.initTxn();
  • 24. 24 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } } catch (KafkaException e) { }txn-status: on-going, partitions: {output-0} producer.initTxn();
  • 25. 25 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } } catch (KafkaException e) { }txn-status: on-going, partitions: {output-0} producer.initTxn();
  • 26. 26 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); } catch (KafkaException e) { }txn-status: on-going, partitions: {output-0} producer.initTxn();
  • 27. 27 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); } catch (KafkaException e) { }txn-status: on-going, partitions: {output-0, offset-0} producer.initTxn(); {output-0}
  • 28. 28 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); producer.commitTxn(); } catch (KafkaException e) { }txn-status: on-going, partitions: {output-0, offset-0} producer.initTxn();
  • 29. 29 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); producer.commitTxn(); } catch (KafkaException e) { }txn-status: prep-commit, partitions: {output-0, offset-0} producer.initTxn(); on-going
  • 30. 30 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); producer.commitTxn(); } catch (KafkaException e) { }txn-status: prep-commit, partitions: {output-0, offset-0} producer.initTxn();
  • 31. 31 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); producer.commitTxn(); } catch (KafkaException e) { }txn-status: prep-commit, partitions: {output-0, offset-0} producer.initTxn();
  • 32. 32 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); producer.commitTxn(); } catch (KafkaException e) { }txn-status: committed, partitions: {output-0, offset-0} producer.initTxn(); prep-commit
  • 33. 33 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); producer.commitTxn(); } catch (KafkaException e) { }txn-status: on-going, partitions: {output-0, offset-0} producer.initTxn();
  • 34. 34 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); producer.commitTxn(); } catch (KafkaException e) { producer.abortTxn(); }txn-status: on-going, partitions: {output-0, offset-0} producer.initTxn();
  • 35. 35 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); producer.commitTxn(); } catch (KafkaException e) { producer.abortTxn(); }txn-status: prep-abort, partitions: {output-0, offset-0} producer.initTxn(); on-going
  • 36. 36 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); producer.commitTxn(); } catch (KafkaException e) { producer.abortTxn(); }txn-status: prep-abort, partitions: {output-0, offset-0} producer.initTxn();
  • 37. 37 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); producer.commitTxn(); } catch (KafkaException e) { producer.abortTxn(); }txn-status: prep-abort, partitions: {output-0, offset-0} producer.initTxn();
  • 38. 38 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(..); producer.commitTxn(); } catch (KafkaException e) { producer.abortTxn(); }txn-status: aborted, partitions: {output-0, offset-0} producer.initTxn(); prep-abort
  • 39. 39 The Kafka Approach for Exactly Once: 1) Idempotent writes in order within a single topic partition 2) Transactional writes across multiple output topic partitions 3) Guarantee single writer for any input topic partitions
  • 40. 40
  • 41. 41
  • 42. 42 At a given time, an input partition should only be processed by a single client
  • 43. 43 At a given time, an input partition should only be processed by a single client Consumer Group
  • 44. 44 At a given time, an input partition should only be processed by a single client Consumer Group
  • 45. 45 At a given time, an input partition should only be processed by a single client Consumer Group
  • 46. 46 The “Single Writer” Fencing Problem
  • 47. 47 When Taking Over the Partition: 1) The previous txn must have completed commit or abort so there are no concurrent transactions. 2) Other clients will be fenced write processing results for those input partitions, a.k.a we have a “single writer”.
  • 48. 48 Transactional ID: defines single writer scope 1) Configured by the unique producer `transactional.id` property. 2) Enforced fencing by a monotonic epoch for each id. 3) Producer initialization await pending transaction completion.
  • 49. 49 Transaction ID: defines single writer scope 1) Configured by the unique producer `transactional.id` property. 2) Enforced fencing by a monotonic epoch for each id. 3) Producer initialization await pending transaction completion.
  • 50. 50 Transaction ID: defines single writer scope 1) Configured by the unique producer `transactional.id` property. 2) Enforced fencing by a monotonic epoch for each id. 3) Producer initialization await pending transaction completion.
  • 51. 51 Consumer Group txn.Id = A, epoch = 1 txn.Id = B, epoch = 1
  • 55. 55 Consumer Group txn.Id = A, epoch = 1 txn.Id = B, initializing...
  • 56. 56 Consumer Group txn.Id = A, epoch = 1 txn.Id = B, epoch = 2
  • 57. 57 Consumer Group txn.Id = A, epoch = 1 txn.Id = B, epoch = 2 Num. producer transaction IDs ~= num. input partitions Producers need to be dynamically created when rebalance
  • 59. 59 Number of Input Partitions Growth of Producers Number of Applications 5 10 15 20 25 30 600 500 400 300 200 1 00
  • 60. 60 Number of Input Partitions At Least Once Growth of Producers Number of Applications 5 10 15 20 25 30 600 500 400 300 200 1 00
  • 61. 61 Number of Input Partitions At Least Once Growth of Producers Number of Applications 5 10 15 20 25 30 600 500 400 300 200 1 00 Exactly Once
  • 64. 64 What problems are KIP-447 solving ? ● Make one producer per process model work
  • 65. 65 What problems are KIP-447 solving ? ● Make one producer per process model work ● Unblock technical challenges ○ Commit fencing ○ Concurrent transaction
  • 66. 66 What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction
  • 67. 67 ● We are fencing on the transactional producer side, which assumes a static partition assignment What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction
  • 68. 68 ● We are fencing on the transactional producer side, which assumes a static partition assignment ● Consumer group partition assignments are dynamic in practice What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction
  • 69. 69
  • 70. 70
  • 71. 71
  • 72. 72
  • 73. 73
  • 74. 74
  • 75. 75 ● We are fencing on the transactional producer side, which assumes a static partition assignment ● Consumer group partition assignments are dynamic in practice ● Action: fence zombie producer commit What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction
  • 76. 76 ● We are fencing on the transactional producer side, which assumes a static partition assignment ● Consumer group partition assignments are dynamic in practice ● Action: fence zombie producer commit ○ Different from epoch fencing ○ Utilize consumer group generation ~= epoch What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction
  • 77. 77
  • 78. 78
  • 79. 79
  • 80. 80
  • 81. 81
  • 82. 82
  • 83. 83
  • 84. 84 ● We are fencing on the transactional producer side, which assumes a static partition assignment ● Consumer group partition assignments are dynamic in practice ● Action: fence zombie producer commit ○ Different from epoch fencing ○ Utilize consumer group generation ~= epoch ● Add new APIs What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction
  • 85. 85 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(offsets); producer.commitTxn(); } catch (KafkaException e) { }txn-status: on-going, partitions: {output, offset}
  • 86. 86 try { producer.beginTxn(); records = consumer.poll(); for (Record rec <- records) { // process .. producer.send(“output”, ..); } producer.sendOffsets(offsets, consumer.groupMetadata()); producer.commitTxn(); } catch (KafkaException e) { } txn-status: on-going, partitions: {output, offset}
  • 87. 87 ● We are fencing on the transactional producer side, which assumes a static partition assignment ● Consumer group partition assignments are dynamic in practice ● Action: fence zombie producer commit ○ Different from epoch fencing ○ Utilize consumer group generation ~= epoch ● Add new APIs ○ Expose group generation through consumer#groupMetadata() ○ Commit transaction with consumer metadata through producer#sendOffsetsToTransaction(offsets, groupMetadata) What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction
  • 88. 88 What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction
  • 89. 89 What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction ● Only one open transaction allowed for each input partition
  • 90. 90 What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction ● Only one open transaction allowed for each input partition ● Offset commit is the only critical section
  • 91. 91 What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction ● Only one open transaction allowed for each input partition ● Offset commit is the only critical section ○ Observed: Pending offsets could be completed later, causing duplicate processing
  • 92. 92 What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction ● Only one open transaction allowed for each input partition ● Offset commit is the only critical section ○ Observed: Pending offsets could be completed later, causing duplicate processing ○ Observed: consumer always needs to fetch offset after rebalance
  • 93. 93 What problems are KIP-447 solving ? ● Commit fencing ● Concurrent Transaction ● Only one open transaction allowed for each input partition ● Offset commit is the only critical section ○ Observed: Pending offsets could be completed later, causing duplicate processing ○ Observed: consumer always needs to fetch offset after rebalance ○ Action: OffsetFetchRequest will back-off until pending commits are cleared, either by previous transaction complete or timeout
  • 94. 94
  • 95. 95
  • 96. 96
  • 97. 97
  • 98. 98
  • 99. 99
  • 101. 101 447 Summary ● Resolve the semantic mismatch between producer and consumer ○ Commit Fencing ○ Concurrent Transaction
  • 102. 102 447 Summary ● Resolve the semantic mismatch between producer and consumer ○ Commit Fencing ○ Concurrent Transaction ● Make the one producer per processing unit possible
  • 103. 103 Number of Input Partitions At Least Once Growth of Producers Number of Applications 5 10 15 20 25 30 600 500 400 300 200 1 00 Exactly Once
  • 104. 104 Number of Input Partitions At Least Once Growth of Producers Number of Applications 5 10 15 20 25 30 600 500 400 300 200 1 00 Exactly Once Exactly Once After 447
  • 105. 105 447 Summary ● Resolve the semantic mismatch between producer and consumer ○ Commit Fencing ○ Concurrent Transaction ● Make the one producer per processing unit possible ● Next we will talk about our scale testing result, and how to turn on 447 for Kafka Streams, a major EOS adopter
  • 107. 107 Prove the 447 scalability improvement to break the limit - At_least_once - Exactly_once - Exactly_once_beta (post KIP-447 EOS) Scale Testing
  • 109. 109 Scale Testing ● Num.brokers = 3 ● Num.input.partitions = 200 ● Num.output.partitions = 100 ● Test.interval.ms = 4 min ● Num.threads = 3 ● Num.records.second = 1000 ● Commit.interval.ms = 1 second ● Num.instances = 10, 20, 30...
  • 110. 110 Scale Testing ● Num.brokers = 3 ● Num.input.partitions = 200 ● Num.output.partitions = 100 ● Test.interval.ms = 4 min ● Num.threads = 3 ● Num.records.second = 1000 ● Commit.interval.ms = 1 second ● Num.instances = 10, 20, 30...
  • 111. 111 Scale Testing ● At_least_once and exactly_once_beta perform steadily ● Exactly_once (pre KIP-447) throughput degrades significantly around 20-25 applications
  • 114. 114 Upgrade Procedure ● Rolling bounce brokers to >= Apache Kafka 2.5
  • 115. 115 Upgrade Procedure ● Rolling bounce brokers to >= Apache Kafka 2.5 ● Upgrade the stream application binary and keep the PROCESSING_GUARATNEE setting at "exactly_once". Do the first rolling bounce, and make sure the group is stable with every instance on 2.6 binary.
  • 116. 116 Upgrade Procedure ● Rolling bounce brokers to >= Apache Kafka 2.5 ● Upgrade the stream application binary and keep the PROCESSING_GUARATNEE setting at "exactly_once". Do the first rolling bounce, and make sure the group is stable with every instance on 2.6 binary. ● Upgrade the PROCESSING_GUARANTEE setting to "exactly_once_beta" and do a second rolling bounce to starts using new thread producer for EOS.
  • 118. 118 Kafka has an elegant transaction model which has held up well.
  • 119. 119 Kafka has an elegant transaction model which has held up well. ● Address hardness with usability by fixing the producer/consumer semantic mismatch
  • 120. 120 Kafka has an elegant transaction model which has held up well. ● Address hardness with usability by fixing the producer/consumer semantic mismatch ● Breakthrough on the scalability
  • 121. 121 Kafka has an elegant transaction model which has held up well. ● Address hardness with usability by fixing the producer/consumer semantic mismatch ● Breakthrough on the scalability ● How to opt-in new EOS model on Kafka Streams
  • 123. 123 - KIP-98 - Exactly Once Delivery and Transactional Messaging - Apache Kafka - KIP-447: Producer scalability for exactly once semantics - Apache Kafka Resources