4

I have a large number of consumer groups created in Kafka. When I check the status most of them are with Empty status and without active consumers.

I have two questions

  1. Automatic deletion of consumer group is supported in Kafka and can we configure a time period to delete the empty consumer groups?
  2. Is there any specific Kafka version which supports automatic deletion of empty Consumer groups?
Vineeth NG
  • 240
  • 3
  • 22
  • [This](https://stackoverflow.com/questions/64137375/kafka-delete-idle-consumer-group-id) might help. – Michael Heil Dec 07 '20 at 14:45
  • You can look at the retention policy for the offsets topic. If there's no active consumers, groups get removed from that topic – OneCricketeer Dec 07 '20 at 15:22
  • @OneCricketeer I tried to find this in the kafka documentation, but was not able to find any details regarding the deletion of groups. Can you please share a link where its mentioned "offsets.retention.minutes" and deleting of groups are mentioned. – Vineeth NG Jul 05 '21 at 10:09
  • `offsets.retention.minutes` is [a broker config](https://kafka.apache.org/documentation/#brokerconfigs_offsets.retention.minutes). The docs dont say "group is deleted"; it says its offsets expire (which cause it not to be in the topic anymore, and therefore cannot be found when queried) – OneCricketeer Jul 06 '21 at 16:16

1 Answers1

7

To delete empty consumer groups, you have 2 options:

  • Do nothing and wait offsets.retention.minutes. This settings defaults to 7 days. Groups without any members for this duration are automatically deleted. This mechanism exists since Kafka 0.8.2!

  • Use the delete consumer group API. This can be used via the Admin API's deleteConsumerGroups method or the kafka-consumer-groups.sh script. This API exists since Kafka 1.1.

Mickael Maison
  • 25,067
  • 7
  • 71
  • 68