1.) Kafka Topics
Topics are the particular stream of data without any constraints unlike in database. You can have as many Topics as you want inside of your cluster and can have as many Topics as you want inside of your cluster. You can store Kafka Topics in any format like json, avro schema etc. You cannot query to access the data from the Kafka but you need Producers to send data and Consumers to read.
2.) Kafka Partitions and Offsets
Topics are split into Partitions.
- Messages in each Partitions are ordered.
- Each message within the idea gets an incremental id called Offsets.
- Kafka Topics are immutable means once the data is written inside of the Partition it cannot be modified.
- Data is only kept for limited time (One week - configurable).
-
Offset only have a meaning for a specific partition.
- Offset 3 in the Partition 0 doesn't have the same data as of the Offset 3 of Partition 1.
- Offsets are not reused even if the previous messages have been deleted.
- Order is guaranteed only within a Partition(not across Partitions).
- Data is assigned randomly to a Partition unless the key is provided.
- You can have as many Partitions as you want as per Topic.
- Messages in each Partitions are ordered.
- Producers write data to the Topics (which are made up of partitions).
- Producers know to which partition to write to (and which Kafka broker has it).
- In case of Kafka broker failures, Producers will automatically recover.