Skip to content
Kafka Is FunProgress

Lesson 1 of 5

Producer Lifecycle & Batching

When you call producer.send(), the record is immediately placed in a RecordAccumulator (an in-memory buffer organized by topic-partition). A background Sender thread batches records from the accumulator and sends ProduceRequests to brokers. linger.ms controls how long to wait before flushing; batch.size caps the batch. Tuning these two is the primary lever for throughput vs latency.

Key configuration

broker / client configurationproperties
linger.ms=0 — send immediately (low latency)
linger.ms=20 — wait 20ms to fill batches (high throughput)
batch.size=16384 — 16KB batch cap
buffer.memory=33554432 — 32MB total producer buffer

Try it in the simulator

Guided scenarios for this module — the simulator opens with the exercise already running.