Difference between Kafka async and Kafka sync acks=0?
Asked Answered
A

1

10

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?

Abernethy answered 10/6, 2021 at 15:45 Comment(1)
Does this answer your question? What is the impact of acknowledgement modes in asynchronous send in kafka?Shush
M
15

Kafka Producers

In Kafka, There is Three type of producers mainly grouped into Async and Sync.

  1. Sync Producer Acks = 0 (Fire and Forget)
  2. Sync Producer Acks = 1 or Acks = all
  3. 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

Maudiemaudlin answered 11/6, 2021 at 4:17 Comment(3)
Does Kafka producer ( ack=1 ) retries if connection with broker is interrupted or incase broker is down ?Coelostat
Yes, If we configure producer with num.of.retries it will retry.Maudiemaudlin
@nipuna: I just read your complete answer as well as the official docs. The concept of acks is also applicable to the Async Producer(kafka.apache.org/36/javadoc/org/apache/kafka/clients/producer/…Fayth

© 2022 - 2025 — McMap. All rights reserved.