简体   繁体   中英

Can multiple consumers of kafka application work on the same thread?

On the below diagram from the Confluent site we can see that multiple consumer tasks can work on the same thread. My question is that if an application consists of multiple consumers (that can read from different topics) can it happen that some of those consumers would work on a single thread.

I am asking this because I also read that:

You can't have multiple consumers that belong to the same group in one thread (...)

which would suggest that in general, it is possible for consumers to share a thread, and that if we tried to set the same group to multiple consumers from a single application, it could sometimes not work. And I did observe behaviour that would match it: when I set the same group for all application consumers, only a part of them did work.

The second question is why when I set num.stream.threads to a number greater to the number of consumers it didn't help.

can it happen that some of those consumers would work on a single thread

No. Kafka Streams create threads based on num.stream.threads config and will create a single KafkaConsumer per thread.

The second question is why when I set num.stream.threads to a number greater to the number of consumers it didn't help.

What do you mean by "great to the number of consumers". There is no "number-of-consumer" config.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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