Skip to content
Kafka Is Fun

Lesson 1 of 5

Producer Lifecycle & Batching

1 min read

Overview

send() is asynchronous. Once metadata is available and the record has been serialized and assigned a partition, the record is added to a buffer of pending sends, organised per partition, and send() returns; a background I/O thread turns buffered records into requests. send() can block for up to max.block.ms while it waits for metadata or for buffer space. linger.ms is an upper bound on how long to wait for more records: once batch.size worth of records for a partition is ready, it is sent immediately. Together the two settings let you trade a little latency for better batching.

Key configuration

Producer settingsproperties
linger.ms=5 — the default since Kafka 4.0 (it was 0 before)
linger.ms=0 — send as soon as possible
batch.size=16384 — default, per partition
buffer.memory=33554432 — default, 32 MiB of memory for buffering records waiting to be sent

Production tip

Check yourself

What happens to a record when you call producer.send()?

Sources

Checked against Kafka 4.2 documentation on Oct 2026. Draft: not yet reviewed by a Kafka specialist. Releases move on, so confirm against the current documentation before you act on a number.

Try it in the simulator

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

Prefer a picture? Open the live cluster in 3D and watch records move between producer, brokers and consumers.

Browse all troubleshooting entries