Why does Kafka achieve such high throughput even though it writes everything to disk?
Short answer
Kafka turns writing into sequential appends to a log, relies on the OS page cache, batches and compresses end to end, and pushes data to the socket with zero-copy; partitions spread the work over many disks and brokers.
3 points to say:
- Sequential, append-only writes, using the page cache instead of a cache inside the JVM.
- End-to-end batching + compression, zero-copy
sendfile(lost once TLS is on), partitions for parallelism. - Trade-offs: per-message latency isn't the lowest, it needs spare RAM for the page cache; consumers reading old data cause disk reads.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.