Apache kafka 卡夫卡没有向消费者发送足够的信息
我有一个卡夫卡主题,3个分区,只有一个消费者。我在消费者端使用spring kafka,并提供以下消费者道具:Apache kafka 卡夫卡没有向消费者发送足够的信息,apache-kafka,spring-kafka,Apache Kafka,Spring Kafka,我有一个卡夫卡主题,3个分区,只有一个消费者。我在消费者端使用spring kafka,并提供以下消费者道具: max.poll.records=10000 fetch.min.bytes=2000000 fetch.max.bytes=15000000 fetch.max.wait.ms=1000 max.poll.interval.ms=300000 auto.offset.reset.config=earliest idle.event.interval=120000 即使有数千条消息(
max.poll.records=10000
fetch.min.bytes=2000000
fetch.max.bytes=15000000
fetch.max.wait.ms=1000
max.poll.interval.ms=300000
auto.offset.reset.config=earliest
idle.event.interval=120000
即使有数千条消息(GB的数据)在队列中等待,kafka消费者在每次轮询中也会收到大约10条消息(总大小约1MB)。消费者应获取批量
fetch.max.bytes
(在我的道具~15MB中)或max.poll.records
(在我的情况下为10000)。问题出在哪里?有几种情况可能导致此问题,请执行以下更改:
fetch.min.bytes
-消费者还可以获取批量fetch.min.bytes
,即1.9MB李>
fetch.max.wait.ms
-轮询函数等待fetch.min.bytes
或fetch.max.wait.ms
触发,无论先发生什么。fetch.max.wait.ms
在您的配置中是1秒,听起来没问题,但增加它以防出现问题max.partition.fetch.bytes
-默认值为1MB,它可以减少像您这样的小分区主题的轮询大小(单个使用者最多可以对3个分区主题进行3MB轮询)李>
尝试使用以下值:
fetch.min.bytes=12000000
fetch.max.wait.ms=5000
max.partition.fetch.bytes=5000000
更深层次的解释:有趣的是,我读了这本书,除了max.partition.fetch.bytes之外,数字与您的建议相同。我想我完全忘了。谢谢增加max.partition.fetch.bytes会显著增加发送给使用者的消息数量。