CCDAK practice question 25 of 25

If I produce to a topic that does not exist, and the broker setting auto.create.topic.enable=true, what will happen?

Full set: 150 questions
Answer options
A: Kafka will automatically create the topic with 1 partition and 1 replication factor
B: Kafka will automatically create the topic with the indicated producer settings num.partitions and default.replication.factor
C: Kafka will automatically create the topic with the broker settings num.partitions and default.replication.factor Correct answer
D: Kafka will automatically create the topic with num.partitions=#of brokers and replication.factor=3
Correct Answer:
C. Kafka will automatically create the topic with the broker settings num.partitions and default.replication.factor
Explanation

When a client requests metadata for a topic that does not exist (e.g., by producing a message to it) and the broker is configured with auto.create.topics.enable=true, the Kafka broker will automatically create the topic. The configuration for this new topic, specifically its partition count and replication factor, is determined by the broker's own default settings. The relevant broker configuration parameters are num.partitions and default.replication.factor. The client's settings do not influence the configuration of an auto-created topic.

Why Incorrect

A. This is incorrect because the partition count and replication factor are not hardcoded to 1. They are determined by the specific values set in the broker's configuration files.
B. This is incorrect because topic creation is a server-side (broker) operation. Producer clients do not have settings that dictate the partition count or replication factor for new topics.
D. This is incorrect because the number of partitions is not determined by the number of brokers, and the replication factor is not hardcoded to 3. Both are explicitly defined by broker configurations.

References

1. Confluent Documentation: In the Broker Configuration reference for Confluent Platform, it specifies the parameters used for auto-created topics:

auto.create.topics.enable: "Enable automatic creation of topics on the server."

num.partitions: "The default number of log partitions per topic."

default.replication.factor: "The default replication factor for automatically created topics."

Source: Confluent Platform 7.5 Documentation, "Broker Configuration Settings".

2. Apache Kafka Documentation: The official Apache Kafka documentation confirms this behavior in its broker configuration section.

num.partitions: "The default number of log partitions per topic." The documentation explicitly states this is the default used when a topic is created.

default.replication.factor: "default replication factors for auto created topics".

Source: Apache Kafka 3.7 Documentation, "Broker Configs", Section 3.3.

Scroll to Top