kafka max.poll.records 設定無效問題
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的配置。