简体   繁体   English

处理批处理记录后如何提交卡夫卡偏移

[英]How to submit kafka offset after processing batch records

I'm using spring-kafka and consuming batch records from kafka topic and submitting offset by AbstractMessageListenerContainer.AckMode.BATCH . 我正在使用spring-kafka并使用kafka主题中的批处理记录,并通过AbstractMessageListenerContainer.AckMode.BATCH提交偏移量。

In my case processing batch records is taking time (approximately 20 seconds), and consumer thread waits until batch process is completed and then do the poll again(submits offset at this poll). 在我的情况下,处理批记录花费时间(大约20秒),并且使用者线程等待直到批处理完成,然后再次进行轮询(在此轮询处提交偏移量)。 In this case i will assign List of records to a thread (name: ProcessThread ) that will process all the records and give result back to consumer thread, and then consumer thread will log the result. 在这种情况下,我将记录List分配给一个线程(名称: ProcessThread ),该线程将处理所有记录并将结果返回给使用者线程,然后使用者线程将记录结果。 (in all this process consumer thread will wait until it gets the results from the ProcessThread , which causing low performance. (在所有此过程中,消费者线程将等待,直到它从ProcessThread获得结果,这会导致性能降低。

Is there any way that ProcessThread will take care of submitting offset to kafka? ProcessThread是否可以通过任何方式将偏移量提交给kafka? so that consumer thread will not need to wait, and for every poll it will create a new processThread 这样使用者线程就不必等待,并且每次轮询都会创建一个新的processThread

In my case i have topic with 20 partitions and 10 pods, each pod with 2 consumer threads (spring kafka concurrent consumers), each poll 100 records (processing all these records by using spring boot threading @Async ) 在我的情况下,我的主题有20个分区和10个pod,每个pod具有2个使用者线程(spring kafka并发使用者),每个轮询100条记录(使用spring boot threading @Async处理所有这些记录)

By above configuration i can process 1 million records in 2 hours and i need to drag it down to at least 40 minutes. 通过以上配置,我可以在2小时内处理100万条记录,而我需要将其拖到至少40分钟。

Any help is Appreciated 😊 任何帮助表示赞赏😊

You should upgrade to at least 1.3.7. 您应该至少升级到1.3.7。 The current version is 2.1.10. 当前版本是2.1.10。 There is no separate thread in those. 这些中没有单独的线程。 Only the consumer thread can send the offsets . 只有使用者线程可以发送偏移量。 The consumer is not thread safe. 使用者不是线程安全的。

You should not hand off to a separate thread. 您不应将其移交给单独的线程。 Use higher concurrency and more partitions. 使用更高的并发性和更多分区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM