Monday, May 29, 2023

Producer Ayarları - acks

Giriş
Açıklaması şöyle
acks denotes the number of brokers that must receive the record before we consider the write to be successful.
Açıklaması şöyle
acks = 0

The producer will not wait for acknowledgment from any of the brokers before we can assume the message was sent successfully. This config option doesn’t let us know if the case message sending failed. This can be considered as fire and forgot and it will let us achieve higher throughput as we do not wait for an acknowledgment.

acks = 1

The producer will wait for acknowledgment from the leader only. If failure is received then we can retry to get it to succeed. We can handle retries by waiting for the message to be successfully sent or we can handle via calls with retry from the code side.

acks = all

The producer will wait till acknowledgment from all the in-sync replicas receives the message. This is safe but a bit slow as we need to wait till we got ack from all the replicas.
acks = all ile bahsedilen in-sync replicas için açıklama şöyle. Ayrıca In-sync Replica - ISR yazısına bakabilirsiniz
An in-sync replica is a replica that fully catches up with the leader in the last 10 seconds
Varsayılan Değer
Varsayılan Değer = 1. Yani Producer, leader broker'dan ack alırsa yeterli kabul eder.

acks=all İse
acks=all şeklinde kullanmak yeterli değil. Kaç tane in-sync replicas istediğimizi belirtmek gerekiyor.. Bunun için min.insync.replicas kullanılır. Varsayılan değer 1. Açıklaması şöyle
The default minimum in-sync replica ( min.insync.replicas) is 1. It means that if all the followers go down, then ISR only consists of the leader. Even if acks is set to all, it actually only commits the message to 1 broker (the leader) which makes the message vulnerable.

The config min.insync.replicas basically defines how many replicas that the producer must receive before considering a successful commit. This config adds on top of acks=all and makes your messages safer. 
Örnek
Şöyle yaparız
props.put(ProducerConfig.ACKS_CONFIG, "0");


No comments:

Post a Comment

kafka-consumer-groups.sh komutu

Giriş Bir topic'i dinleyen consumer'ları gösterir. Aynı topic'i dinleyen consumer group'ları olabilir. Her topic farklı part...