kafka ack=all and min-isr
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka is a distributed streaming platform that enables high-throughput, fault-tolerant delivery of messages. A key component of Kafka's reliability and durability is its message acknowledgment mechanism along with its replication factor strategy. Two critical configurations in this context are acks and min.insync.replicas (min ISR). Understanding how both settings work is vital for effectively managing Kafka's performance and data integrity.
Understanding acks
The acks setting in Kafka determines the number of acknowledgments the producer requires the leader to have received before considering a request complete. This setting has three primary values:
acks=0: The producer will not wait for any acknowledgment from the server. This setting provides the lowest latency but the highest risk of data loss.acks=1: The producer will receive a success response from the leader as soon as the leader has written the record to its local log but before any followers have replicated it. This provides better latency thanacks=allbut still carries a risk of data loss if the leader fails immediately after receiving the message.acks=all(oracks=-1): This setting ensures the highest data durability. The producer will receive a success response only when all current in-sync replicas (ISRs) have received the record. This minimizes the risk of data loss but increases the latency.
Importance of min.insync.replicas
The min.insync.replicas setting defines the minimum number of replicas that must acknowledge a record before the producer's write request is considered successful, used in conjunction with acks=all. This setting helps ensure that sufficient replicas have the data to avoid data loss, particularly in the failure scenarios where one or more replicas go offline.
Practical Use Cases and Implications
- Data Safety: Using
acks=allwith an adequatemin.insync.replicasensures that data is not acknowledged before being replicated, protecting against data loss during unforeseen failures. - Performance Trade-offs: While
acks=allprovides stronger data guarantees, it can significantly affect throughput and latency due to the overhead of waiting for multiple acknowledgments.
Working Example
Consider a Kafka cluster with one topic, TopicA, with a replication factor of 3. If min.insync.replicas is set to 2, then at least two of the three replicas must acknowledge receipt of the message for a write operation to be considered successful when acks=all is used. This ensures that even if one broker goes down, another broker still has the data.
Configuration and Implementation
To implement these settings, configurations in the producer and broker are required:
Producer Configuration:
Broker Configuration:
With these settings, Kafka only acknowledges messages that have been written to the log of the leader and replicated to at least one additional broker.
Summarizing Table
| Setting | Value | Description |
acks | 0, 1, all | Determines the acknowledgment level. all ensures full replication before acknowledgment. |
min.insync.replicas | integer | Minimum number of replicas that must ack before a message is considered as successfully written. |
Conclusion
Combining acks=all with a suitably configured min.insync.replicas provides a robust setup for data integrity in Kafka. However, users must balance the need for high data reliability against the potential performance impacts due to increased latency and lower throughput. These settings are crucial for scenarios where data loss is unacceptable, such as financial transactions or highly critical application events.
Related reading
- Kafka Acknowledgment vs Kafka commit
- Kafka ACL issue using Java code
- kafka AdminClient API Timed out waiting for node assignment
- Kafka and Akka Cluster
- Kafka and hotspots in a partition
- Kafka AND REST for communication between microservices?
- Kafka and firewall rules
- KAFKA and SSL java.lang.OutOfMemoryError Java heap space when using kafka-topics command on KAFKA SSL cluster

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.