gpt4 book ai didi

apache-kafka - Kafka 生产者超时异常

转载 作者:行者123 更新时间:2023-12-02 08:29:31 24 4
gpt4 key购买 nike

我正在运行一个 Samza 流作业,该作业将数据写入 Kafka 主题。 Kafka 正在运行一个 3 节点集群。 Samza 作业部署在 yarn 上。我们在容器日志中看到很多此类异常:

 INFO [2018-10-16 11:14:19,410] [U:2,151,F:455,T:2,606,M:2,658] samza.container.ContainerHeartbeatMonitor:[ContainerHeartbeatMonitor:stop:61] - [main] - Stopping ContainerHeartbeatMonitor
ERROR [2018-10-16 11:14:19,410] [U:2,151,F:455,T:2,606,M:2,658] samza.runtime.LocalContainerRunner:[LocalContainerRunner:run:107] - [main] - Container stopped with Exception. Exiting process now.
org.apache.samza.SamzaException: org.apache.samza.SamzaException: Unable to send message from TaskName-Partition 15 to system kafka.
at org.apache.samza.task.AsyncRunLoop.run(AsyncRunLoop.java:147)
at org.apache.samza.container.SamzaContainer.run(SamzaContainer.scala:694)
at org.apache.samza.runtime.LocalContainerRunner.run(LocalContainerRunner.java:104)
at org.apache.samza.runtime.LocalContainerRunner.main(LocalContainerRunner.java:149)
Caused by: org.apache.samza.SamzaException: Unable to send message from TaskName-Partition 15 to system kafka.
at org.apache.samza.system.kafka.KafkaSystemProducer$$anon$1.onCompletion(KafkaSystemProducer.scala:181)
at org.apache.kafka.clients.producer.internals.RecordBatch.done(RecordBatch.java:109)
at org.apache.kafka.clients.producer.internals.RecordBatch.maybeExpire(RecordBatch.java:160)
at org.apache.kafka.clients.producer.internals.RecordAccumulator.abortExpiredBatches(RecordAccumulator.java:245)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:212)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:135)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.kafka.common.errors.TimeoutException: Expiring 5 record(s) for Topic3-16 due to 30332 ms has passed since last attempt plus backoff time

这 3 种类型的异常经常出现。

59088 org.apache.kafka.common.errors.TimeoutException: Expiring 115 record(s) for Topic3-1 due to 30028 ms has passed since last attempt plus backoff time

61015 org.apache.kafka.common.errors.TimeoutException: Expiring 60 record(s) for Topic3-1 due to 74949 ms has passed since batch creation plus linger time

62275 org.apache.kafka.common.errors.TimeoutException: Expiring 176 record(s) for Topic3-4 due to 74917 ms has passed since last append

请帮我理解这里的问题是什么。每当发生这种情况时,Samza 容器都会重新启动。

最佳答案

该错误表明某些记录放入队列的速度比从客户端发送的速度快。

当您的生产者发送消息时,它们会存储在缓冲区中(在将消息发送到目标代理之前),并且记录会分组在一起以提高吞吐量。当新记录添加到批处理中时,必须在可配置的时间窗口内发送,该时间窗口由 request.timeout.ms 控制(默认设置为 30 秒)。如果批处理在队列中的时间较长,则会引发 TimeoutException,然后批处理记录将从队列中删除,并且不会传递给代理。

增加 request.timeout.ms 的值应该可以解决问题。

如果这不起作用,您还可以尝试减小batch.size,以便更频繁地发送批处理(但这次将包含更少的消息)并确保逗留。 ms 设置为 0(这是默认值)。

请注意,更改任何配置参数后,您需要重新启动 kafka 代理。

如果您仍然收到错误消息,我认为您的网络出现问题。您启用了 SSL 吗?

关于apache-kafka - Kafka 生产者超时异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53223129/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com