kafka max.poll.records 设置无效问题

张映 发表于 2019-05-06

分类目录: hadoop/spark/scala

标签:

kafka设置了max.poll.records为50000条,但是只能读取到1400条左右,没有任何报错。估计应当是配置问题。

1,解决办法,要调整以下三个参数

    pros.put("max.partition.fetch.bytes","104857600")
    pros.put("fetch.min.bytes ","2108576")
    pros.put("fetch.max.wait.ms","10000")

2,参数说明

fetch.max.wait.ms

Fetch请求发给broker后,在broker中可能会被阻塞的(当topic中records的总size小于fetch.min.bytes时),此时这个fetch请求耗时就会比较长。这个配置就是来配置consumer最多等待response多久。

fetch.min.bytes

当consumer向一个broker发起fetch请求时,broker返回的records的大小最小值。如果broker中数据量不够的话会wait,直到数据大小满足这个条件。
取值范围是:[0, Integer.Max],默认值是1。
默认值设置为1的目的是:使得consumer的请求能够尽快的返回。

max.partition.fetch.bytes

一次fetch请求,从一个partition中取得的records最大大小。如果在从topic中第一个非空的partition取消息时,如果取到的第一个record的大小就超过这个配置时,仍然会读取这个record,也就是说在这片情况下,只会返回这一条record。
broker、topic都会对producer发给它的message size做限制。所以在配置这值时,可以参考broker的message.max.bytes 和 topic的max.message.bytes的配置。



转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/hadoop/2133.html