真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

KafkaProducer重試參數(shù)retries設(shè)置取舍的示例分析

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

站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到軹城網(wǎng)站設(shè)計(jì)與軹城網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、申請(qǐng)域名、網(wǎng)頁(yè)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋軹城地區(qū)。

1.retries參數(shù)說(shuō)明

參數(shù)的設(shè)置通常是一種取舍,看下retries參數(shù)在版本0.11.3說(shuō)明:

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.

備注:當(dāng)發(fā)送失敗時(shí)客戶端會(huì)進(jìn)行重試,重試的次數(shù)由retries指定,此參數(shù)默認(rèn)設(shè)置為0。即:快速失敗模式,當(dāng)發(fā)送失敗時(shí)由客戶端來(lái)處理后續(xù)是否要進(jìn)行繼續(xù)發(fā)送。如果設(shè)置retries大于0而沒(méi)有設(shè)置max.in.flight.requests.per.connection=1則意味著放棄發(fā)送消息的順序性。

2.retries使用建議

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

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

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

3.retries后續(xù)發(fā)展

該參數(shù)的設(shè)置已經(jīng)在kafka 2.4版本中默認(rèn)設(shè)置為Integer.MAX_VALUE;同時(shí)增加了delivery.timeout.ms的參數(shù)設(shè)置。

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

看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。


文章名稱:KafkaProducer重試參數(shù)retries設(shè)置取舍的示例分析
本文URL:http://weahome.cn/article/pdeigo.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部