Junior — Middle
Can you explain how a Kafka Topic is organized and operates?
sobes.tech AI
Answer from AI
Kafka Topic is a logical category or stream of messages to which data is published and from which consumers read.
How a Topic is organized:
- Partitions: each Topic is divided into several partitions — ordered, immutable sequences of messages. Partitions allow scaling processing and provide parallelism.
- Offset: each message in a partition has a unique sequential number — offset, which consumers use to track which messages have already been read.
- Replication: partitions can have replicas on different brokers for fault tolerance.
How a Topic works:
- A producer sends messages to the Topic, Kafka distributes them across partitions (e.g., by key or round-robin).
- Messages are written to the end of partitions and stored on disk.
- Consumers read messages from partitions, using the offset they control themselves.
Thus, a Topic provides an ordered, scalable, and fault-tolerant message exchange system.