Kafka: delete an unused consumer group with kafka-consumer-groups.sh
Codemia Knowledge Hub ·
To delete an unused Kafka consumer group, run kafka-consumer-groups.sh --bootstrap-server <host>:<port> --group <group-name> --delete. First confirm the group is really unused: it has no active consumers and has not committed offsets recently.
What a consumer group is
A consumer group is one or more consumers that together consume a set of subscribed topics. Groups provide load balancing and fault tolerance: Kafka spreads a topic's partitions across the group's consumers, so each message is processed once by the group while partitions are consumed in parallel.
Why clean up stale groups
Unused groups pile up over time, especially with dynamic scaling or frequent configuration changes. Removing them helps with:
- Resources: each group keeps metadata and state in the cluster.
- Broker overhead: fewer groups can mean less work for the brokers and better performance.
- Cost: in managed Kafka environments such as Confluent Cloud, you might be charged based on the number of consumer groups.
- Monitoring: fewer groups are easier to monitor and operate.
Finding unused consumer groups
A group counts as unused when it has no active consumers connected and hasn't committed offsets recently. List the groups and their status:
--list and --describe cannot be combined; --describe --all-groups --state prints each group's state and member count. Look for groups in the Empty state with 0 members, or a long time since the last commit.
Deleting the group
This marks the consumer group for deletion. When the group is actually removed from the cluster depends on the Kafka version and the server configuration.
| Action | Command | Description |
| List Groups | kafka-consumer-groups.sh --bootstrap-server <host>:<port> --list | Lists all consumer groups |
| Describe Group | kafka-consumer-groups.sh --bootstrap-server <host>:<port> --group <group-name> --describe | Shows detailed info on a specific group |
| Delete Group | kafka-consumer-groups.sh --bootstrap-server <host>:<port> --group <group-name> --delete | Deletes the specified consumer group |
Precautions and automation
- Recovery: have a backup, or an easy way to recreate a group deleted by mistake.
- Version support: the ability to delete consumer groups has evolved, and older Kafka versions might not support it directly.
- Automated cleanup: in dynamic environments with many transient groups, build group monitoring and cleanup into your standard operations with custom scripts or third-party tools that can detect and purge unused groups.
Related reading
- delete.retention.ms at the time of creating topic in kafka on 0.8.1 version
- Deleting all pending tasks in celery?
- Deleting queues in RabbitMQ
- Demultiplexing messages from a queue to process in parallel streams using amqp?
- Description of TF Lite's Toco converter args for quantization aware training
- design a stack such that getMinimum should be O1
- Deserialize Avro messages into specific datum using KafkaAvroDecoder
- Deserializing a kafka message without schema registry
System design interview problems on this topic
- Design a Distributed Messaging System: solution and walkthrough
- Design a Log Collection and Analysis System: solution and walkthrough
- Design an Ad Click Aggregation System: solution and walkthrough
- Design a Webhook Notification Service: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.