卡夫卡新制片人超时 [英] Kafka new producer timeout

查看:46
本文介绍了卡夫卡新制片人超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用新的kafka生产者客户端,并将timeout.ms属性设置为50 ms.

I'm using the new kafka producer client and set the timeout.ms property to 50 ms.

这是生产者中使用的完整配置:

Here is the complete configuration used in the producer:

props.put("acks", "1");
props.put("buffer.memory", "33554432");
props.put("retries", "1");
props.put("batch.size", "16384");
props.put("client.id", "foo");
props.put("linger.ms", "0");
props.put("timeout.ms", "50");

在某些高负载情况下,请求的平均响应时间为4秒,但我没有收到任何超时错误.

The request average response time in some moments of high load is 4 seconds, but I don't get any timeout error.

有人知道该超时如何计算,何时开始计数以及何时结束吗?有没有一种方法可以配置超时,以从调用生产者的send方法的那一刻开始?

Does Someone know how this timeout is calculated, when it begins to be counted and when it finishes? Is there a way to configure a timeout to start from the moment the producer's send method is called?

推荐答案

新的 timeout.ms 属性与生产者的 ack 配置一起使用.例如,考虑以下情况

The new timeout.ms property works with the ack configuration of the producer. For example consider the following situation

ack = all
timeout.ms = 3000

在这种情况下, ack = all 意味着领导者直到收到完整的同步副本(ISR)的确认后才会响应,并且获得此确认的最大等待时间为 3000毫秒.如果在给定时间内未收到预期的确认数,则会返回错误.

In this case ack = all means that the leader will not respond untill it receives acknowledgement for the full set of in-sync replicas (ISR) and the maximum wait time to get this acknowledgement will be 3000 ms. If it didn't receive the expected number of acknowledgements within the given time it will return an error.

还请注意,此属性未考虑网络延迟.

Also note this property does not consider network latency.

在文档页面上:

该配置控制服务器等待来自跟随者的确认以满足生产者通过acks配置指定的确认要求的最长时间.如果超时后未满足请求的确认数,将返回错误.此超时是在服务器端测量的,不包括请求的网络延迟.

The configuration controls the maximum amount of time the server will wait for acknowledgments from followers to meet the acknowledgment requirements the producer has specified with the acks configuration. If the requested number of acknowledgments are not met when the timeout elapses an error will be returned. This timeout is measured on the server side and does not include the network latency of the request.

因此,对于您来说,如果<领导者>无法响应(在将记录写到其记录上之后),我的回答是 ack = 1 (对此我不是100%的肯定,并且可以进行任何更正).自己的日志而没有等待所有关注者的完全确认)在50毫秒之内会引发错误.

So in your case with ack=1 (I am not 100% sure about this and open to any correction if applicable) if the leader is not able to respond (after writing the record to its own log without awaiting full acknowledgement from all followers) within 50ms should throw an error.

这篇关于卡夫卡新制片人超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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