Integration / Apache Kafka Interview questions
What is a Kafka offset used for?
An offset is a sequential, per-partition number Kafka assigns to each record as it's appended to the log — 0, 1, 2, and so on, within that specific partition. Its main job is tracking consumption progress: a consumer records which offset it has processed up to in each assigned partition, so it knows exactly where to resume if it restarts or a partition gets reassigned to a different consumer during a rebalance.
consumer.commitSync(); // commits the offsets of the most recently polled records
Consumers can commit offsets automatically on an interval (enable.auto.commit=true) or manually via commitSync()/commitAsync() for tighter control over exactly when "processed" is recorded relative to actual work being done — a distinction that directly determines whether an application behaves closer to at-least-once or at-most-once delivery. Committed offsets themselves are stored durably in an internal Kafka topic (__consumer_offsets), not on the consumer's local machine, so progress survives a consumer restarting on a different host entirely.
More Related questions...