Each segment consists of three files: .log (the actual messages), .index (sparse offset-to-byte-position index), and .timeindex (sparse timestamp-to-offset index). When a consumer requests offset N, Kafka uses the .index to binary-search to the nearest entry, then scans forward. This O(log n) lookup + sequential scan is extremely efficient.
Key configuration
log.index.interval.bytes=4096 — index entry every 4KB of data
log.index.size.max.bytes=10485760 — max index file size