Updated on 2025-09-15 GMT+08:00

Changing Kafka Partition Quantity

After creating a topic, you can change the number of partitions as required. Changing the number of partitions does not restart the instance or affect services.

Methods for changing the partition quantity:

Notes and Constraints

  • The number of partitions can only be increased.
  • Instances created since May 15, 2024 do not have Kafka Manager. You cannot modify topic partitions for these instances using Kafka Manager.
  • The partition quantity of topics of a single-node or cluster Kafka instance is limited. When the partition quantity limit is reached, you can no longer create topics. The total number of partitions varies with instance specifications. For details, see Kafka Instance Specifications.
  • For an instance with ciphertext access enabled, if allow.everyone.if.no.acl.found is set to false, the topic partition quantity can be modified on the client only by the initial user (set in first ciphertext access enablement).

Repartitioning a Topic on the Console

  1. Log in to the Kafka console.
  2. Click in the upper left corner to select the region where your instance is located.
  3. Click the desired instance to go to the instance details page.
  4. In the navigation pane, choose Topics.
  5. Modify the number of partitions using either of the following methods:

    • Select one or more topics and click Edit Topic in the upper left corner.
    • In the row containing the desired topic, click Edit.

  6. In the Edit Topic dialog box, enter the number of partitions and click OK.

    To ensure performance, a maximum of 200 partitions is allowed for each topic on the Kafka console.

    View the partition quantity on the Topics page.

Modifying Topic Partitions on Kafka Manager

  1. Log in to Kafka Manager.
  2. Choose Topic > List to view the list of topics.
  3. Click a topic to view its details.
  4. Click Add Partitions.

    Figure 1 Topic details page

  5. Enter the number of partitions and click Add Partitions.

    To ensure performance, 200 or less partitions are recommended for each topic.
    Figure 2 Adding partitions

    If "Done" is displayed, the partitions are added successfully.

    Figure 3 Partitions added

Modifying Topic Partitions on the Client

If your Kafka client version is later than 2.2, you can use kafka-topics.sh to change the partition quantity.

  • For a Kafka instance with ciphertext access disabled, run the following command in the /bin directory of the Kafka client:
    ./kafka-topics.sh --bootstrap-server {connection-address} --topic {topic-name} --alter --partitions {number-of-partitions}
    Table 1 Topic partition quantity parameters

    Parameter

    Description

    connection-address

    Connection address of a Kafka instance. To obtain the address, choose Basic Information > Connection.

    topic-name

    Topic name.

    number-of-partitions

    Number of partitions in the topic.

    To ensure performance, 200 or fewer partitions are recommended for each topic.

    Example:

    [root@ecs-kafka bin]# ./kafka-topics.sh --bootstrap-server 192.168.xx.xx:9092,192.168.xx.xx:9092,192.168.xx.xx:9092 --topic topic-01 --alter --partitions 6
    [root@ecs-kafka bin]#
  • For a Kafka instance with ciphertext access enabled, do as follows:
    1. (Optional) If the username and password, and the SSL certificate has been configured, skip this step and go to 2. Otherwise, do as follows:

      Create the ssl-user-config.properties file in the /config directory of the Kafka client. Add the username and password, and the SSL certificate configuration by referring to 3.

    2. Run the following command in the /bin directory of the Kafka client:
      ./kafka-topics.sh --bootstrap-server {connection-address} --topic {topic-name} --alter --partitions {number-of-partitions} --command-config ../config/{ssl-user-config.properties} 
      Table 2 Topic partition quantity parameters

      Parameter

      Description

      connection-address

      Connection address of a Kafka instance. To obtain the address, choose Basic Information > Connection.

      topic-name

      Topic name.

      number-of-partitions

      Number of partitions in the topic.

      To ensure performance, 200 or fewer partitions are recommended for each topic.

      ssl-user-config.properties

      Configuration file name. This file contains username, password, and SSL certificate information.

      Example:

      [root@ecs-kafka bin]# ./kafka-topics.sh --bootstrap-server 192.168.xx.xx:9093,192.168.xx.xx:9093,192.168.xx.xx:9093 --topic topic-01 --alter --partitions 6 --command-config ../config/ssl-user-config.properties
      [root@ecs-kafka bin]#

Related Documents