2. Me
• Software engineer @ Confluent
• Committer on Apache Kafka
• Co-author of
“Kafka - the Definitive Guide”
• Tweets a lot: @gwenshap
• Learning to devops
6. Partitions
• Kafka organizes messages into
topics
• Each topics have a set of
partitions
• Each partition is a replicated log
of messages, referenced by
sequential offset
Partition 0
Partition 1
Partition 2
0 1 2 3 4 5
0 1 2 3 4 5 6 7
0 1 2 3 4
Offset
7. Replication
• Each Partition is replicated 3
times
• Each replica lives on separate
broker
• Leader handles all reads and
writes.
• Followers replicate events
from leader.
01234567
Replica 1 Replica 2 Replica 3
01234567
01234567
Producer
25. 25
What not to do. Ever:
cat /dev/null > /data/log/my_topic-
15/00000000000001548736.log
While Kafka is up and running.
26. 26
When you are in a hole
Stop digging.
Don’t know where the holes are?
Walk slowly.
27. 27
General Tips for
Stable Kafka
● Over-provision
● Upgrade to latest bug-fixes
● Don’t mess with stuff you don’t
understand.
● Call support when you have to
60. 61
You don’t really know how your
software will behave until it is in
production for quite a while.
61. 62
More Key Points
● Keep an eye on your key resources
● Tread carefully in unknown territory
● Sometimes crashed broker is GOOD
● Monitor user scenarios -
especially for SLAs
When you download Apache Kafka, you get a cluster of brokers, Java clients, connector framework and stream processing libraries. We are going to talk about the cluster bits. Although all bits need to be monitored.
Those two messages are sent async, so you may see few log messages where broker 101 tries to follow broker 102 and fails because broker 102 doesn’t know it is a leader yet. This should resolve itself in few ms.
As you may have noticed, the “best scenario” is somewhat complex. There are lots of moving parts. So today we are taking a look at cases where things did not go as expected.
You know things are bad when the BEST CASE is a crash. But this case is relatively easy:
Get bigger disks. Easy on AWS, GCP and on most advanced storage system.
Adjust retention policy and delete some large partitions by deleting entire directory (make sure they are not leaders!)
You know things are bad when the BEST CASE is a crash. But this case is relatively easy:
Get bigger disks. Easy on AWS, GCP and on most advanced storage system.
Adjust retention policy and delete some large partitions by deleting entire directory (make sure they are not leaders!)
This is snatching defeat from jaws of victory.
If you are close to running out of space, but not there yet, you can do a lot of adjustments to retention or you can cleanly shut down the broker.
The above “solution” will go undetected by the broker until someone tries to access an offset with non-existing data. Since the index still points to the now-empty file, this will be seen as corruption and can lead to crashes (depending on exact scenario).
If this already happened, you don’t have lots of options.
Note that this is a good solution because the alert is very actionable. Look at the awesome runbook! You can do this even at 2am.
When you are close to the limit in any of those, the brokers will be unhealthy. Small things can
When you are close to the limit in any of those, the brokers will be unhealthy. Small things can tip Kafka over the edge.
The most stable systems are overprovisioned
Brendan Gregg USE method is useful to understand the current state: http://www.brendangregg.com/usemethod.html
Somewhat related problem except worse
The moment you stop the broker, downtime is over.
If you don’t want to be an expert… there are options.