Middle
What is the difference between a partition and a topic in Kafka?
sobes.tech AI
Answer from AI
In Apache Kafka, a topic is a logical category or stream of messages where producers publish data and consumers read them. A topic can be thought of as a channel or subject for messages.
A partition is a physical segment of a topic, representing an ordered, immutable log of messages. Each topic is divided into one or more partitions for scalability and parallel processing.
Main differences:
- A topic is a logical entity that groups messages by subject.
- A partition is a physical segment of a topic that stores messages in the order they were written.
- Partitions enable scaling of the topic and provide parallelism.
Example: a topic "orders" might have 3 partitions, each storing a part of the order messages.