在 Kaka Producer 中配置重试的最佳方式 [英] Best way to configure retries in Kaka Producer

查看:27
本文介绍了在 Kaka Producer 中配置重试的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

同步副本配置为 Acks=allmin.insync.replicas = N

With In-Sync replicas configured as Acks=all and min.insync.replicas = N,

想了解如何为未处理的生产者记录的消息/记录配置重试

Want to understand how retries should be configured for the message/record for unprocessed producer records

示例:当Kafka处理记录失败时,ISR online在处理过程中为N-1,最小配置的ISR为N个副本.

Example: When Kafka fails to process the record with ISR online was N-1 during processing and minimum configured ISR was N replicas.

推荐答案

什么是acks?

acks 参数控制在生产者认为写入成功之前必须接收多少分区副本.

The acks parameter control how many partition replicas must receive the record before the producer can consider the write successful.

acks 参数有 3 个值:

There are 3 values for the acks parameter:

acks=0,生产者在假设消息发送成功之前不会等待代理的回复.

acks=0, the producer will not wait for a reply from the broker before assuming the message sent successfully.

acks=1,生产者将在领导副本收到消息的那一刻收到代理的成功响应.如果消息无法写入领导者,生产者将收到错误响应并可以重试.

acks=1, the producer will receive a successful response from the broker the moment the leader replica received the message. If the message can't be written to the leader, the producer will receive an error response and can retry.

acks=all,一旦所有同步副本都收到消息,生产者将收到来自代理的成功响应.

acks=all, the producer will receive a successful response from the broker once all in-sync replicas received the message.

在您的情况下,acks=all,这是最安全的方法,因为您可以确保另外一个经纪人收到消息.

In your case, acks=all, which is the safest way since you can make sure one more broker has the message.

重试:

如果生产者收到错误信息,那么 retries 属性的值就出现了.您可以使用 retry.backoff.ms 属性来配置重试之间的时间.建议测试从崩溃的 broker 中恢复需要多长时间,并设置重试次数和它们之间的延迟,这样重试的总时间将比 Kafka 集群从头恢复所需的时间长.

If the producer receives the error message, then the value of the retries property comes into the picture. You can use retry.backoff.ms property to configure the time between retries. It is recommended, test how long it takes to recover from a crashed broker and setting the number of retries and delay between them such that the total amount of time spent retrying will be longer than the time it takes the Kafka cluster to recover from scratch.

另外,检查下面的链接,

Also, check the below link,

https://www.confluent.io/blog/hands-free-kafka-replication-a-lesson-in-operational-simplicity/

这篇关于在 Kaka Producer 中配置重试的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆