Home
Performance
Cheat Sheets
Hub
Kafka Core
Cheat Sheets
Cheat Sheets
Three dense quick references by persona—producer/consumer/Spring for developers, Streams/Connect/schemas for data engineers,
and ops/metrics/security for platform. Use Copy sheet for plain text, persona filters to focus one role, or print (Cmd/Ctrl+P).
developer
senior
platform
Developer
Data Engineer
Platform
Delivery semantics
Semantic Producer Consumer When
At-most-once acks=0, no retryCommit before process Metrics, loss OK
At-least-once acks=all, retriesProcess then commit Default production
Exactly-once (Kafka) Idempotent + transactions read_committedStreams, txn listeners
# Durable producer (at-least-once on wire)
acks=all
enable.idempotence=true
retries=2147483647
max.in.flight.requests.per.connection=5
Producer config
Property Safe prod Throughput Low latency
acksall11
linger.ms5200
batch.size1638413107216384
compression.typelz4lz4none
buffer.memory33554432134217728—
enable.idempotencetruetruetrue
// Async — never .get() per record in hot loop
kafkaTemplate.send("orders", key, event); // CompletableFuture in Spring Kafka 3.x
Consumer config
Property Typical Notes
group.idorder-serviceOne per logical app
auto.offset.resetearliestNew group only
enable.auto.commitfalseManual ack after process
max.poll.records500× process time < max.poll.interval.ms
max.poll.interval.ms300000+Rebalance if exceeded
isolation.levelread_committedTransactional producers
fetch.min.bytes1 / 100000Latency / throughput
Spring Kafka
API Purpose
KafkaTemplate.send(...)Async produce; returns CompletableFuture
@KafkaListenerDeclarative consumer; containerFactory for custom ack/error
AcknowledgmentManual commit — needs MANUAL ackMode
@SendToRequest-reply reply routing
DefaultErrorHandlerRetry + DLT via DeadLetterPublishingRecoverer
@RetryableTopicNon-blocking retry topics + DLT
ReplyingKafkaTemplateRPC-style request-reply client
@KafkaListener(topics = "orders", groupId = "processor")
public void onOrder(@Payload OrderEvent o, Acknowledgment ack) {
process(o);
ack.acknowledge();
}
spring.kafka.listener.ack-mode: record
spring.kafka.listener.concurrency: 3
Partitioning & keys
Strategy Behavior
Key provided murmur2(key) % partitions — same key → same partition
No key, partition set Explicit partition
No key, no partition Sticky partition batching (producer)
Custom Partitioner implementation
CLI quick ref
kafka-console-producer.sh --bootstrap-server kafka:9092 --topic orders
kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic orders --from-beginning --group debug
kafka-topics.sh --describe --topic orders --bootstrap-server kafka:9092
kafka-consumer-groups.sh --describe --group order-processor --bootstrap-server kafka:9092
Kafka Streams DSL
Type Semantics Backing topic
KStreamEvent stream (every record) delete retention
KTableChangelog per key (latest) compact
GlobalKTableFull copy on every instance Compacted, small catalog
streams.builder()
.stream("orders")
.groupByKey()
.windowedBy(TimeWindows.ofSizeWithNoGrace(Duration.ofMinutes(5)))
.count()
.toStream()
.to("order-counts");
# EOS
processing.guarantee=exactly_once_v2
isolation.level=read_committed
Connect & Debezium
Component Role
Connector Plugin + config (JdbcSource, Debezium, S3Sink)
Task Unit of parallelism (tasks.max)
Worker JVM running tasks; REST :8083
SMT Single Message Transform in-flight
DB CDC mechanism
PostgreSQL Logical replication (pgoutput)
MySQL Binlog ROW format
MongoDB Change streams / oplog
Oracle LogMiner
# Debezium envelope fields
op: c|u|d|r before / after source.ts_ms ts_ms
# Outbox SMT
transforms=outbox
transforms.outbox.type=io.debezium.transforms.outbox.EventRouter
# Error handling
errors.tolerance=all
errors.deadletterqueue.topic.name=connect.dlq
Schema Registry
Compatibility Rule (intuition)
BACKWARDNew consumer reads old data — add fields with default
FORWARDOld consumer reads new data — remove with default
FULLBoth directions vs latest version
FULL_TRANSITIVEBoth vs all history — prod default
NONENo checks — avoid shared topics
Wire: 0x00 + schema_id (4 bytes BE) + payload
Subject: orders-value (TopicNameStrategy)
auto.register.schemas=false # CI registers schemas
Architecture patterns
Pattern Use when Gotcha
Outbox + CDC DB + Kafka atomic publish At-least-once; idempotent consumers
CQRS Separate read/write models Eventual consistency in UX
Event sourcing Replayable audit log Snapshot for long aggregates
Saga orchestration Multi-service txn Compensations must be idempotent
DLT Poison messages {topic}.DLT + metadata headers
Fan-out Multiple independent consumers Separate consumer groups
MirrorMaker 2 DR / multi-region Active-active needs conflict rules
Performance tuning matrix
Knob Throughput Low latency
linger.ms20 0
compression.typelz4 none
fetch.min.bytes100000 1
fetch.max.wait.ms500 0
acks1 (unsafe) 1 or all
partitions ≈ target_MB/s ÷ per_partition_MB/s (measure!)
Per partition: ~10-100 MB/s depending on disk/NIC
kafka-producer-perf-test.sh --topic perf --record-size 1024 --throughput -1 ...
kafka-consumer-perf-test.sh --topic perf --messages 5000000 ...
Reliability checklist
Layer Must have
Topic RF=3, min.insync.replicas=2
Producer acks=all, idempotence
Consumer Idempotent handler or dedup store
Broker unclean.leader.election.enable=false
Schema FULL_TRANSITIVE, no auto-register in prod