# Create Kafka Consumer Group (from CLI)

Published 2022-12-03

This tutorial explains to you how to create a Kafka consumer group from CLI. This tutorial has an example as well.

Sometimes only one consumer is not enough. You must have more consumers in order to consume all the messages received by Kafka Topics. The scaling is done by adding more consumers to the same consumer group.

When you create a consumer without a consumer group a consumer group will be created by default. When you add more consumers to the same consumer group, all the consumers will consume the messages received by the topic. The partitions are associated with the consumers. If you have 5 consumers and 4 partitions, one consumer will do nothing, but if a consumer goes down the idle consumer will start consuming messages.

When you create a consumer you have to add the consumer group to be part of that consumer group. This is very simple. You have to run the following command:

kafka-console-consumer.sh --topic my-topic10 --bootstrap-server localhost:9092 --group order_application

Here it is an example:

In order to see the consumer groups you have to run the kafka-consumer-groups.sh script:

If you want to get more information about the consumers of a consumer group, you can run the following command:

kafka-consumer-groups.sh --describe --group order_application --members --bootstrap-server localhost:9092

You can see on which partition a consumer is listening.