Apache Kafka Best Practices
SkillMediaApache Kafka 4.2 best practices for event streaming, topic design, and producer-consumer patterns
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Apache Kafka Best Practices skill
What this skill tells your AI
The instructions your AI receives, as published by baekenough/oh-my-customcode in .claude/skills/kafka-best-practices/SKILL.md and read by ahel’s review.
Version: Kafka 4.2.0. ZooKeeper is fully removed in Kafka 4.x — use KRaft mode for all cluster deployments.
Producer Patterns
Idempotent Producer (CRITICAL)
- Enable
enable.idempotence=true - Prevents duplicate messages
- Requires
acks=all,retries > 0,max.in.flight.requests.per.connection <= 5
Exactly-Once Semantics
- Use transactional API:
initTransactions(),beginTransaction(),commitTransaction() - For exactly-once end-to-end processing
Performance
- Batching:
linger.ms(wait for batch to fill) - Compression:
compression.type=snappyorlz4 batch.size: 16KB default, tune based on message size
Consumer Patterns
Offset Management
- Auto-commit:
enable.auto.commit=true(at-least-once) - Manual commit:
commitSync()orcommitAsync()(better control)
Rebalancing
- Cooperative sticky assignor: minimal rebalancing disruption
session.timeout.msandheartbeat.interval.mstuning
At-Least-Once vs Exactly-Once
- At-least-once: default, idempotent processing required
- Exactly-once: transactional consumer + producer
Topic Design
Partitioning
- Partition count: based on throughput (MB/s ÷ partition throughput)
- Key-based partitioning for ordering guarantees
- More partitions = higher throughput (but more overhead)
Retention
- Time-based:
retention.ms - Size-based:
retention.bytes - Log compaction: for changelog topics (
cleanup.policy=compact)
References
Signals
- GitHub stars
- 34
- Forks
- 6
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
kafka-best-practices- Source
- github.com/baekenough/oh-my-customcode