What is producer acknowledgment and what modes exist (acks=0,1,all)?
The producer does not wait for any acknowledgment from the broker. The message is considered successfully sent as soon as it enters the network buffer.
Answer (Senior+)
Producer Acknowledgment (acks) is a producer configuration parameter that determines how many acknowledgments from broker replicas the producer must receive to consider a message write successful. This is the primary lever for balancing between reliability (Durability) and speed (Latency).
1. ACKS Modes
acks = 0 (Fire and Forget)
The producer does not wait for any acknowledgment from the broker. The message is considered successfully sent as soon as it enters the network buffer.
- Latency: Minimal.
- Reliability: Zero. If the broker goes down or a network failure occurs — data is lost permanently.
- Use Case: Log or metric collection where losing 1–2% of data is acceptable.
acks = 1 (Leader Only) — Default before Kafka 3.0. Starting with Kafka 3.0 (KIP-316), the default changed to acks=all.
The producer waits for acknowledgment only from the partition Leader. The leader writes data to its local log and immediately responds to the producer.
- Latency: Medium.
- Reliability: Medium. If the Leader goes down immediately after responding to the producer but before Followers could copy the data — the data is lost.
- Use Case: General business events that don’t require extreme reliability.
acks = all (or -1) — Default in newer versions
The producer waits for acknowledgment from the Leader and all in-sync replicas (ISR).
- Latency: Maximum (limited by the slowest replica in ISR).
- Reliability: Maximum. Data is guaranteed to be saved on multiple nodes.
- Use Case: Financial transactions, critical data.
2. Relationship with min.insync.replicas
Senior insight: The acks=all parameter alone does not guarantee writing to multiple nodes. If only one Leader remains in ISR, acks=all effectively becomes acks=1.
To guarantee real redundancy, you need to use the min.insync.replicas parameter at the broker or topic level (e.g., set it to 2 with replication.factor=3).
3. Impact on Retries
When using acks=1 or all, the producer may receive errors (e.g., NotLeaderForPartitionException). In this case, it will automatically retry (retries) if configured. With acks=0, retries are impossible because the producer is unaware of the error.
Summary for Senior
acks=0: Speed at any cost.acks=1: Balance (risky on leader failure).acks=all: maximum reliability, but higher latency (waiting for the slowest ISR replica) and lower availability (when ISR < min.insync.replicas, writes are blocked).- Always use
acks=alltogether withmin.insync.replicas >= 2for critical data. - Remember that
acks=allprotects against data loss but not duplicates (idempotence is needed for that).
🎯 Interview Cheat Sheet
Must know:
acks=0— fire and forget, minimal latency, zero reliabilityacks=1— acknowledgment from leader, medium reliability; data is lost if the leader goes downacks=all— acknowledgment from all ISR, maximum reliability; higher latencyacks=allwithoutmin.insync.replicas>=2=acks=1if ISR=1- Default changed: before Kafka 3.0 — acks=1; from Kafka 3.0 (KIP-316) — acks=all
- Retries are possible with acks=1/all; with acks=0 the producer is unaware of the error
acks=allprotects against data loss but not duplicates (idempotence is needed)
Common follow-up questions:
- Why is acks=all without min.insync.replicas insufficient? — If ISR=1, acks=all = acks=1.
- What is the default in Kafka 3.0+? — acks=all (KIP-316), previously it was acks=1.
- What happens with acks=all and ISR < min.insync.replicas? — NotEnoughReplicasException, write is rejected.
- Does acks=all slow down writes? — Yes, latency is limited by the slowest ISR replica.
Red flags (DO NOT say):
- “acks=0 for production data” — zero delivery guarantee
- “acks=all guarantees writing to multiple nodes without min.insync.replicas” — if ISR=1, it writes to one
- “acks=0 supports retries” — the producer is unaware of the error
- “acks=all protects against duplicates” — no, idempotence is needed
Related topics:
- [[16. What is replication in Kafka]]
- [[18. What is ISR (In-Sync Replicas)]]
- [[9. What delivery guarantees does Kafka provide]]
- [[23. What is idempotent producer]]