Updated on 2024-04-07 GMT+08:00

(Optional) Step 3: Create a Topic

A topic is a stream of messages. If automatic topic creation is not enabled during Kafka instance creation, you need to manually create topics for creating and retrieving messages. If automatic topic creation is enabled, this step is optional. The system automatically creates a topic when a message is created. This topic has the following default settings: 3 partitions, 3 replicas, aging time 72 hours, and synchronous replication and flushing disabled.

The following describes how to manually create topics on the console.

Procedure

  1. Log in to the Kafka console, and select the region where the Kafka instance is located.
  2. Click a Kafka instance.
  3. On the Topics page, click Create Topic.
  4. Enter the topic name, specify other parameters, and click OK.

    Table 1 Topic parameters

    Parameter

    Description

    Topic Name

    Specify the name.

    Cannot be changed once the topic is created.

    Partitions

    Set it to 3.

    The more partitions, the higher the consumption concurrency.

    Replicas

    Set it to 3.

    Kafka automatically backs up data on each replica. If one broker is faulty, data will still be available. Reliability increases with the number of replicas of a topic.

    NOTE:

    If an instance node is faulty, an internal service error may be reported when you query messages in a topic with only one replica. Therefore, you are not advised to use a topic with only one replica.

    Aging Time (h)

    Set it to 72.

    How long messages will be preserved in the topic. Messages older than this period cannot be consumed. They will be deleted, and can no longer be retrieved.

    Synchronous Replication

    Do not enable it.

    Synchronous Flushing

    Do not enable it.