Why Is Kafka So Fast? Uncover the 4 Core Performance Secrets

This article explains the four key techniques—page‑cache usage, sequential disk writes, zero‑copy transfers, and partitioned segment indexing—that enable Kafka to achieve exceptionally high write performance, detailing how each mechanism reduces latency and maximizes throughput.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Why Is Kafka So Fast? Uncover the 4 Core Performance Secrets
Kafka performance diagram
Kafka performance diagram

Kafka's high performance is a frequent interview topic; this article highlights four core reasons.

1. Page Cache

Kafka writes to the operating system's page cache (os cache), allowing data to be written to memory first; the OS later flushes it to disk, effectively turning disk writes into memory writes.

Disk IO steps
Disk IO steps

2. Sequential Disk Writes

Kafka appends data to the end of files, avoiding random writes. Sequential writes eliminate seek time and reduce rotational latency, improving I/O efficiency.

Disk seek, rotation, transfer
Disk seek, rotation, transfer

Seek time – moving the head to the correct track.

Rotational latency – waiting for the sector to rotate under the head.

Data transfer – moving data between disk, memory, and network.

3. Zero Copy

Traditional data flow copies data from memory to the Kafka process, then to the socket buffer, incurring extra copies.

Kafka uses Linux's sendfile to transfer data directly from the OS cache to the socket, skipping user‑space copies.

Non-zero copy data flow
Non-zero copy data flow
Zero copy with sendFile
Zero copy with sendFile

4. Partitioning, Segmentation & Indexing

Messages are stored per‑topic and further divided into partitions, each mapped to a directory on the filesystem. Partitions are split into segments, and Kafka creates an index (.index) for each segment.

This design enables efficient reads and parallel processing.

Partition and segment layout
Partition and segment layout
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performanceBackend DevelopmentKafkaZero CopyPartitioningpage cacheSequential Write
Mike Chen's Internet Architecture
Written by

Mike Chen's Internet Architecture

Over ten years of BAT architecture experience, shared generously!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.