NOTE
Reading Kafka Source Code
A value-first route through Kafka source: protocol requests, producer batching, broker append/fetch, replication, group coordination, and KRaft metadata.
This is a historical learning note and may contain outdated or incomplete understanding.
1. Read Source Around a Question
Kafka is large. Do not read packages linearly.
Start from a concrete question such as:
- how does a producer batch and retry?
- how is a Produce request appended to a partition log?
- how does a follower fetch replication data?
- how are consumer-group offsets coordinated?
- how does KRaft commit metadata changes?
2. Suggested Path
- client producer / record accumulator / sender;
- Kafka protocol request/response types;
- broker request handling;
- partition/log append and fetch;
- replica management;
- group coordinator;
- controller/KRaft metadata path.
3. Version Matters
Kafka internals changed substantially from ZooKeeper-era controllers to KRaft, and client/broker implementation details continue to evolve.
Always read the source tag matching the deployed version and distinguish public protocol/semantics from one implementation’s internal class layout.