Kafka Topic creation upon specific broker
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Apache Kafka is a distributed streaming platform capable of handling trillions of events a day. Primarily, Kafka is used for building real-time streaming data pipelines and applications that adapt to the data streams. One of the fundamental concepts in Kafka is the topic, which is essentially a category or feed name to which records are published.
Understanding Kafka Topics
A Kafka topic is a user-defined category through which Kafka maintains feeds of messages in the form of records. Topics in Kafka are always multi-subscriber; that is, a topic can have zero, one, or many consumers that subscribe to the data written to it.
Key Characteristics
- Partitioned: Topics are divided into partitions, allowing for data to be scaled horizontally across multiple Kafka brokers.
- Replicated: Each partition can be replicated across multiple Kafka brokers to ensure fault tolerance and high availability.
- Immutable Sequence: Records in a partition are immutable and are identified by their offset.
Creating Topics on Specific Broker
While you cannot directly create a topic on a specific Kafka broker — since topics are properties of the entire Kafka cluster — you can influence where partitions of a topic reside through careful broker and topic configuration management.
Step-by-Step Guide to Create a Topic
- Pre-Requisites: Ensure that Kafka is installed and that your cluster is up and running. Make sure you have access to the Kafka command line tools.
- Command Line Creation: You can use the Kafka command line tool to create topics. The basic syntax is:
Here, <broker-list> is a list of brokers in the format host1:port1,host2:port2.
Example:
- Validate Topic Creation: Check if the topic has been created successfully with the describe command:
Configuring Topic Placement
While you can't specify a "specific" broker for a topic, you can use the concept of broker rack awareness to control the distribution of topic partitions across different physical racks or brokers.
Broker Rack Awareness Setup
You need to configure the broker.rack parameter in the broker’s config file (e.g., server.properties). Assign each broker a rack ID (which can also simulate a logical grouping of brokers).
Then update the topic's configuration to spread the partition across different racks using the replica.selector.class for custom control.
Summary Table of Kafka Topic Commands
| Command | Description | Example Command |
| Create Topic | Create a new topic in the Kafka cluster. | kafka-topics.sh --create |
| Describe Topic | Get details about one or more topics. | kafka-topics.sh --describe |
| List Topics | List all topics in the cluster. | kafka-topics.sh --list |
| Delete Topic | Delete a topic from the cluster. | kafka-topics.sh --delete |
Best Practices for Topic Creation
- Plan Capacity: Understand the message size and rate to appropriately configure partitions and replicas.
- Monitor: Regularly monitor topic and partition health across the cluster.
- Security: Configure ACLs for topic authorization to control who can produce and consume data.
Understanding topic creation and management in Kafka is crucial for effective data stream management in large-scale environments. This knowledge ensures not only performance but also durability and fault tolerance of your data streams.

