What is a Kafka topic?

In Kafka, a topic is a category or stream of messages that are stored and processed by Kafka. It is similar to a table in a database or a folder in a filesystem, and can be thought of as a logical container for the messages that are produced and consumed by Kafka.

A topic is identified by a name, which is used by producers and consumers to specify which messages they want to produce or consume. Topics can have one or more partitions, which are used to distribute the load of producing and consuming messages across multiple brokers in a Kafka cluster.

Messages within a topic are ordered by their offset, which is a unique identifier assigned to each message as it is produced. Consumers can consume messages from a topic in order, or they can specify a specific offset to start consuming from.

Topics can be created and managed using the Kafka command-line tools or the Kafka API. When a topic is created, administrators can specify the number of partitions to use, as well as other configuration settings such as the replication factor, retention period, and compression settings.

Overall, topics are a fundamental concept in Kafka and are used to organize and manage the flow of messages within a Kafka cluster.