How to delete kafka consumer group (created via new consumer api)?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka is a distributed event streaming platform capable of handling trillions of events a day. One essential aspect of Kafka is the concept of consumer groups, which allow multiple consumers to read from the same topic, distributing the workload. This detailed overview covers how to delete a Kafka consumer group that was created using the new consumer API, introduced in version 0.9 of Kafka.
Understanding Consumer Groups
In Kafka, a consumer group consists of one or more consumers who subscribe to a common set of topics and share the workload of consuming messages. Each consumer within a group reads from exclusive partitions of the topic, ensuring that no two consumers process the same message.
Why Delete a Consumer Group?
Deleting a consumer group might be necessary during maintenance, application decommission, or to reset the state of the consumer group. When a consumer group is deleted, its offsets (which track the progress of each consumer in the group on a per-partition basis) are also removed. This means that if a new group is created with the same name, it will start consuming messages from either the earliest offset or the latest, depending on the configuration.
How to Delete a Consumer Group
The deletion of a consumer group is typically carried out using Kafka's command line tools, particularly kafka-consumer-groups.sh. This tool allows for various management actions on consumer groups.
Requirements
- Kafka Broker: Your Kafka environment must be running, and you should know the broker's IP address and port.
- Command Line Access: Access to the Kafka installation directory, specifically where the
bindirectory is located. - Group Name: The exact name of the consumer group you wish to delete.
Step-by-Step Guide
- Open your command line tool: Access your Kafka server where the Kafka binaries are installed.
- Navigate to the Kafka
bindirectory: This directory contains all the scripts needed to manage Kafka.
- Use the
kafka-consumer-groups.shtool to delete the group:
Replace <broker-ip>, <broker-port>, and <group-name> with your Kafka broker's IP address, port, and the name of the consumer group, respectively.
Example
If your Kafka broker is running on localhost:9092 and the consumer group name is test-group, the command would be:
Important Considerations
- Kafka Version Compatibility: The delete option for consumer groups was added in Kafka 0.9. Be sure that your Kafka version supports this feature.
- Consumer Group State: You can only delete a consumer group if it is empty, meaning no consumers are currently active in the group.
- Impact: Deleting a consumer group resets its offset. This could lead to message reprocessing or loss, depending on the situation and new consumer configurations.
Summary Table
| Feature | Detail |
| Minimum Kafka Version | 0.9 |
| Tool Used | kafka-consumer-groups.sh |
| Requirement | Broker must be running; Consumer group must be inactive/empty |
| Command Syntax | ./kafka-consumer-groups.sh --bootstrap-server <broker:port> --delete --group <group> |
| Common Use Case | Resets consumer offset; Useful for testing or redevelopment |
Additional Resources
For more advanced Kafka management tasks, including altering consumer groups or troubleshooting, consult the Kafka documentation or community forums. Managing consumer groups effectively is crucial for optimizing Kafka's performance and reliability in production environments.
Deleting a Kafka consumer group is a straightforward task when using the command-line tools provided by Kafka, and knowledge of when and how to properly delete a group is vital for maintaining the health and efficiency of your Kafka streaming applications.
Related reading
- how to delete kafka message after reading
- How to delete Kafka topic using Kafka REST Proxy?
- How to delete multiple topics in Apache Kafka
- How to delete the consumer offset of a group for one specific topic
- How to deploy and serve prediction using TensorFlow from API?
- How to deploy TURN servercoturn inside Kubernetes
- How to deploy Kafka Stream applications on Kubernetes?
- How to deploy Kafka Streaming Application on Kafka Cluster

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.