Explain Kafka topics, partitions and offsets.
A topic is a named stream of records. It is split into partitions, which are the unit of ordering, parallelism and replication. Records within a partition are strictly ordered and appended; each gets a monotonically increasing offset.
Consumers read from a partition and commit offsets to remember their position. A consumer group assigns each partition to exactly one consumer, so parallelism is capped by the partition count.
topic: orders
partition 0: [0][1][2][3]
partition 1: [0][1][2]
The message key determines the partition, so all records with the same key land in the same partition and preserve order. That is how you keep per-customer or per-order ordering while still scaling. Partitions also determine replication: each has a leader and followers, and the leader handles reads and writes. Increasing partitions later is possible but changes key-to-partition mapping, so plan capacity up front.