liveBook · Manning

Page cache

As explained in Apache Kafka in Action

A page cache is an operating-system memory cache that stores file data in memory to accelerate reads and defer writes to storage.

A page cache is operating-system memory that temporarily holds file data. Kafka writes incoming records there instead of forcing an immediate disk write, allowing sequential access patterns to remain fast while the operating system persists data in the background. section 6.3 section 8.5

A Kafka write typically follows this path:

  • A producer sends a record to the broker. section 8.5
  • The broker places the record in the operating system’s page cache; network threads queue requests for I/O threads. section 8.5
  • The broker may acknowledge the producer after the record reaches main memory and, with replication configured, after followers receive it. section 6.3 section 8.5
  • The operating system later flushes cached data to storage. section 6.3

A replicated write

A producer sends a record to a Kafka leader. The leader places it in the page cache and can acknowledge it before an immediate disk write. If followers replicate the record, that replication—not instant local disk persistence—provides the main protection against a single broker failure. A power failure can still lose data held only in memory, while simultaneous failures across brokers can cause permanent loss. section 6.3 section 8.5

The same data format can enable Linux zero-copy transfer: the kernel changes pointers rather than copying data between network memory and the page cache. TLS introduces additional processing and prevents this optimization. A full storage volume is especially dangerous because cached data may be lost; monitoring capacity and stopping Kafka before exhaustion are safer operational practices. section 6.3 section 16.1.3

How Apache Kafka in Action covers it

How deep it goes
Explains write acknowledgment, background flushing, zero-copy limits, and storage-exhaustion risks without detailing kernel internals.
Examples
Uses producer-to-broker writes, follower replication, power failure, TLS, zero-copy transfer, and full-volume failure as concrete cases.
What it assumes
Assumes familiarity with Kafka producers and brokers while explaining page-cache persistence and replication relationships incrementally.
What you can do after
Evaluate Kafka durability and performance trade-offs involving acknowledgments, replication, TLS, disk flushing, and storage capacity.
How it connects
Connects page cache with Kafka brokers, replication, acknowledgments, sequential I/O, zero-copy transfer, TLS, and storage monitoring.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.