日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Kafka Producer重试参数retries设置取舍的示例分析

發布時間:2023/12/15 综合教程 56 生活家
生活随笔 收集整理的這篇文章主要介紹了 Kafka Producer重试参数retries设置取舍的示例分析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Kafka Producer重試參數retries設置取舍的示例分析,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。

1.retries參數說明

參數的設置通常是一種取舍,看下retries參數在版本0.11.3說明:

Setting a value greater than zero will cause the client to resend
any record whose send fails with a potentially transient error.
Note that this retry is no different than if the client resent the
record upon receiving the error.
Allowing retries without setting max.in.flight.requests.per.connection to 1 will potentially change
the ordering of records because if two batches are sent to a single
partition, and the first fails and is retried but the second succeeds,
then the records in the second batch may appear first.

備注:當發送失敗時客戶端會進行重試,重試的次數由retries指定,此參數默認設置為0。即:快速失敗模式,當發送失敗時由客戶端來處理后續是否要進行繼續發送。如果設置retries大于0而沒有設置max.in.flight.requests.per.connection=1則意味著放棄發送消息的順序性。

2.retries使用建議

使用retries的默認值交給使用方自己去控制,結果往往是不處理。所以通用設置建議設置如下:

retries = Integer.MAX_VALUE
max.in.flight.requests.per.connection = 1

備注:這樣設置后,發送客戶端會一直進行重試直到broker返回ack;同時只有一個連接向broker發送數據保證了數據的順序性。在Leader選舉、集群中一個broker掛掉時,發送端會一直重試直到Leader選舉結束。避免由于客戶端對異常未處理造成的數據丟失,例如:遇到類似“This server is not the leader for that topic-partition”會自動恢復。

3.retries后續發展

該參數的設置已經在kafka 2.4版本中默認設置為Integer.MAX_VALUE;同時增加了delivery.timeout.ms的參數設置。

The default value for the producer's retries config was changed to
Integer.MAX_VALUE, as we introduced delivery.timeout.ms in KIP-91,
which sets an upper bound on the total time between sending a
record and receiving acknowledgement from the broker.
By default, the delivery timeout is set to 2 minutes.

KIP-91: https://cwiki.apache.org/confluence/display/KAFKA/KIP-91+Provide+Intuitive+User+Timeouts+in+The+Producer

總結

以上是生活随笔為你收集整理的Kafka Producer重试参数retries设置取舍的示例分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。