Based on my readings, Kafka with acks=0 basically just pushes the message into the producer buffer. It does not wait for any sort of acks. With that, I'm wondering how it is different from async producer? How does acks affect the async producer?
Kafka Producers
In Kafka, There is Three type of producers mainly grouped into Async and Sync.
- Sync Producer Acks = 0 (Fire and Forget)
- Sync Producer Acks = 1 or Acks = all
- Async Producer
Sync Producer Acks = 0 (Fire and Forget)
In Fire and Forget Scenario we are not wait for any response and there is no any retries. So, There is no guarantee that message is delivered or not. So in this case there is
- Possible loss of messages
- High throughput
- No Retries
Sync Producer Acks = 1 or Acks = all
In Sync producer with acks = 1
, The producer will wait for the response from the leader of the partition. So there is a guarantee only from partition leader broker. But there is a message loss possibility if leader broker crashed and there is no In sync replicas for that. Throughput is lower than Async and Fire and Forget And retries are as producer retries configuration.
In Sync producer with acks = all
, The producer will wait for the response from the leader of the partition and the all In sync Replicas. So there is a guarantee from partition leader broker and In sync Replica brokers. We can make sure number of In sync replicas with Min In sync Replica
configuration. Throughput is lowest And retries are as producer retries configuration. But highest reliable producer.
Async Producer
Async Producer almost same as Fire and Forget producer but there is some differences. It has a callback function to get if there is any response from the broker side. But producer is not waiting for that response, It is happening in the background. So difference is there is a trace if broker send some producer errors and there is retries. Because of Async retries, The order of the messages is not guarantee.
And there is a configuration called max.in.flight.requests.per.connection
. Async number of messages are limited to this number if there is no any response from previous messages. So if this is full, again Async producer will be block until this responses coming to the producer.
For more Information, Please refer
num.of.retries
it will retry. –
Maudiemaudlin © 2022 - 2025 — McMap. All rights reserved.