I have one kafka topic with some high number of partitions, say 100 (fixed), and I have a spring boot application which has kafka listeners(or say consumer) consuming from the topic. Now I know that using concurrency
property you can adjust the number of consumer threads, something like this (controlling it via application.properties
file):
@KafkaListener(groupId = "${someGroupID}",
topics = "${someTopic}",
containerFactory = "someKafkaListenerContainerFactory",
concurrency = "${concurrencyProperty}")
{
//some logic
}
Using concurrency
property on @KafkaListener
I can fix the number of consumer threads but if I want to dynamically adjust that number during runtime based on the request load (say if all consumer threads are occupied, render 5 new consumer threads), is there anyway to do this?
Or let me know if there are any better practices to manage the consumer threads according to the load. Thanks.
NOTE: I have kept topic partition count as fixed to a high number since increasing that number could bring in consumer re-balancing delays which as far as I know can be very time consuming, so I am planning to keep the partition count as fixed.