liveBook · Manning

Topic alteration

As explained in Apache Kafka in Action

Topic alteration is the Kafka operation that changes supported properties of an existing topic.

Topic alteration changes an existing Kafka topic when its original capacity or reliability is no longer sufficient. It avoids deleting and recreating the topic, which would risk losing its data. section 3.1.2

Increase partitions without recreating the topic

For products.prices.changelog, increase the partition count from two to three with kafka-topics.sh --alter --topic products.prices.changelog --partitions 3 --bootstrap-server localhost:9092. The existing partitions retain their leaders and replicas; Kafka adds partition 2 with broker 2 as leader and broker 3 as another replica. section 3.1.2

$ kafka-topics.sh \
    --alter \
    --topic products.prices.changelog \
    --partitions 3 \
    --bootstrap-server localhost:9092

Use the alteration command as a starting point, then describe the topic to verify its new partition count and broker assignments. section 3.1.2 section 3.1.2

How Apache Kafka in Action covers it

How deep it goes
Demonstrates the alteration command and resulting broker assignments, but warns only that reducing partitions is impossible.
Examples
Demonstrates increasing products.prices.changelog from two to three partitions and inspecting the resulting distribution.
What it assumes
Assumes familiarity with Kafka topics, partitions, replicas, leaders, brokers, and the kafka-topics.sh command.
What you can do after
Apply it via kafka-topics.sh to increase partitions and verify leaders and replicas with topic description.
How it connects
Connects topic alteration with partitions, replicas, leaders, brokers, and data preservation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.