Create Apache Kafka® topics
Create topics in your Aiven for Apache Kafka® service to organize message streams between producers and consumers.
Understand Kafka topics
A topic in Aiven for Apache Kafka® is a named stream of messages. Producers send data to topics, and consumers read from them.
Aiven for Apache Kafka® supports two topic types:
- Classic topics: Store data on local disks and optionally offload older data to object storage through tiered storage.
- Diskless topics: Store data directly in object storage, such as AWS S3 or Google Cloud Storage.
Both topic types can coexist in the same service. The topic type cannot be changed after creation. For guidance on choosing between them, see Compare diskless and classic topics.
For limitations and restrictions of diskless topics, see Limitations of diskless topics.
Before you begin
Before creating topics in your Aiven for Apache Kafka® service, review the following:
- Tiered storage applies only to classic topics. When enabled, all new topics use tiered storage by default. See Tiered storage.
- Manual topic creation gives you control over partitions, replication, and retention, helping prevent accidental topic creation. It’s preferred in production.
- Automatic topic creation applies only to classic topics. You can enable it to create topics automatically when a message is produced to a non-existent topic. See Automatically create topics.
Create an Apache Kafka topic
- Console
- CLI
- Terraform
-
In the Aiven Console, select the Aiven for Apache Kafka service.
-
In the sidebar, click Topics.
-
Click Create topic.
-
In Topic type, select one of the following:
- Classic topic: Data is stored on local disks and can optionally use tiered storage.
- Diskless topic: Data is stored in object storage.
-
Enter a name in the Topic field.
-
Optional: Under Edit advanced configuration, turn on Custom settings and adjust topic parameters such as partitions, replication factor, and retention.
noteCompaction is not available for diskless topics.
-
Optional: Click Add configuration to define additional Kafka parameters if needed.
-
Classic topics only: Under Tiered storage, you can enable or disable the feature.
- Tiered storage cannot be disabled once enabled.
- Configure local retention options if needed.
-
Click Create topic.
After creation, the topic appears on the Topics page. The Topic type column indicates whether the topic is Classic, Tiered, or Diskless.
You can create topics using the Aiven CLI.
- Classic topic
- Diskless topic
To create a classic topic using the Aiven CLI:
avn service topic-create \
--project <PROJECT_NAME> \
--service-name <SERVICE_NAME> \
--topic <TOPIC_NAME> \
--partitions <PARTITION_COUNT> \
--replication <REPLICATION_FACTOR>
To create a diskless topic using the Aiven CLI:
avn service topic-create \
--project <PROJECT_NAME> \
--service-name <SERVICE_NAME> \
--topic <TOPIC_NAME> \
--partitions <PARTITION_COUNT> \
--replication <REPLICATION_FACTOR> \
--diskless-enable
Parameters:
<PROJECT_NAME>
: Aiven project that contains the Kafka service.<SERVICE_NAME>
: Aiven for Apache Kafka® service name.<TOPIC_NAME>
: Name of the topic.<PARTITION_COUNT>
: Number of partitions to distribute messages.--replication <REPLICATION_FACTOR>
: Number of replicas for each partition.--diskless-enable
: Creates a diskless topic by storing data in object storage.
- Classic topic
- Diskless topic
Manage topics using the
aiven_kafka_topic
resource.
To use diskless topics, enable them in the Kafka service through
the aiven_kafka
resource before defining topics
with aiven_kafka_topic
.
Related pages