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

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

问题描述

将同步副本配置为 Acks = all min.insync.replicas = N

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

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

示例:当Kafka在处理过程中无法通过ISR在线处理记录时,记录为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:

确认 = 0,在假定消息发送成功之前,生产者将不等待经纪人的答复.

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

确认 = 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 属性来配置两次重试之间的时间.建议测试从崩溃的代理恢复所需的时间,并设置重试次数和它们之间的延迟,以使重试所花费的总时间长于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.

还请检查以下链接,

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

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

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