QuickDevGuide

Home › Apache Kafka

Java Producer: Acks, Batching & Idempotence — Apache Kafka

The producer batches records per partition and sends them asynchronously. Setting Recommended Effect acks all wait for all in-sync replicas — no data loss on leader failure enable.idempotence true (default in 3.x) no duplicates from retries, per-partition ordering kept retries / delivery.timeout.ms defaults (MAX / 120 s) retry transient errors until the timeout linger.ms 5–20 wait a little to fill batches → higher throughput batch.size 32–64 KB max bytes per partition batch compression.type lz4 / zstd smaller network & disk usage max.in.flight.requests.per.connection ≤ 5 required ≤ 5 for idempotence Delivery semantics At most once — acks=0, fire and forget. At least once — acks=all + retries (possible duplicates downstream). Exactly once — idempotent producer + transactions (next…

Key Takeaways