Kafka's ACK mechanism

Kafka's ACK mechanism is a data backup strategy that occurs between producers and Kafka clusters

Those of us who have used Kafka should know that when creating a topic, there will only be replication-factor.

 ./kafka-topics.sh --create --zookeeper 192.168.85.133:2181,192.168.85.134:2181,192.168.85.135:2181 --replication-factor 2 --partitions 1 --topic test

For example, in my above command, the original one copy plus two backups is three copies of data. One of these three copies of data will be used by Kafka as the leader, and the other two copies will be used as followers.

When the data is pushed to Kafka by the producer, it is first pushed to the leader. At this time, we will talk about our ACK mechanism. Before talking about the use of ack, we need to know that the leader will push to other followers after the data is received. Let the follower back up this data. If there is an accident in the process, it will be skipped. Later, the leader will try to push again after a period of time. Now let’s talk about the specific role of ACK.

The ACK value is 1 by default, and the producer will continue to push the next piece of data until the leader returns the feedback that the leader itself has successfully received the data. At this time, the speed of data transmission, that is, the throughput, is moderate, but there is also a disadvantage that data cannot be guaranteed. Must be successfully backed up by other followers

When the ACK mechanism value is 0, the producer will not wait for any feedback and directly send the next piece of data. At this time, the data throughput is the fastest, but the data security is the lowest. There is no guarantee that the data will be received from the source.

When the value of the ACK mechanism is -1, the producer will still wait for the leader's feedback, but this feedback is not only the leader's own, but also all other followers. At this time, the data throughput is the lowest, but the data Security level is the highest

Guess you like

Origin blog.csdn.net/dudadudadd/article/details/114404672