Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase number of partitions in a Kafka topic from a Kafka client

Tags:

apache-kafka

I'm a new user of Apache Kafka and I'm still getting to know the internals.

In my use case, I need to increase the number of partitions of a topic dynamically from the Kafka Producer client.

I found other similar questions regarding increasing the partition size, but they utilize the zookeeper configuration. But my kafkaProducer has only the Kafka broker config, but not the zookeeper config.

Is there any way I can increase the number of partitions of a topic from the Producer side? I'm running Kafka version 0.10.0.0.

like image 292
kudoXI Avatar asked Jan 05 '23 12:01

kudoXI


2 Answers

As of Kafka 0.10.0.1 (latest release): As Manav said it is not possible to increase the number of partitions from the Producer client.

Looking ahead (next releases): In an upcoming version of Kafka, clients will be able to perform some topic management actions, as outlined in KIP-4. A lot of the KIP-4 functionality is already completed and available in Kafka's trunk; the code in trunk as of today allows client to create and to delete topics. But unfortunately, for your use case, increasing the number of partitions is still not possible yet -- this is in scope for KIP-4 (see Alter Topics Request) but is not completed yet.

TL;DR: The next versions of Kafka will allow you to increase the number of partitions of a Kafka topic, but this functionality is not yet available.

like image 147
Michael G. Noll Avatar answered Jan 13 '23 14:01

Michael G. Noll


It is not possible to increase the number of partitions from the Producer client. Any specific use case use why you cannot use the broker to achieve this ?

But my kafkaProducer has only the Kafka broker config, but not the zookeeper config.

I don't think any client will let you change the broker config. You can only access (read) the server side config at max.

like image 41
Manav Garg Avatar answered Jan 13 '23 14:01

Manav Garg