Model answers for 4 Kafka questions
Typical round: fundamentals, guarantees, one incident scenario
Q: How does Kafka guarantee ordering? A: Only within a partition. Messages with the same key go to the same partition, so per-key order is preserved. If you need ordering per order ID, use the order ID as the key; global ordering needs a single partition, which limits throughput.
Q: What happens when a consumer joins a group? A: The group rebalances and partitions are reassigned so each partition is read by exactly one consumer in the group. More consumers than partitions leaves some idle, so partition count caps parallelism.
Q: How do you get exactly-once processing? A: Enable the idempotent producer, use transactions to write outputs and commit consumer offsets atomically, and read with isolation.level=read_committed. When writing to external systems, make the sink idempotent instead.
Q: Consumer lag keeps growing. What do you do? A: Check whether consumers are slow (processing time, downstream calls) or too few for the partitions, look for frequent rebalances, then scale consumers up to the partition count, batch work, or add partitions if throughput needs it.