An I/O thread is a Kafka broker thread that processes queued broker input and output. Network threads place producer and consumer requests in the request queue; I/O threads then handle the request and place the result in the response queue. section 8.2.1 section 9.2
For a produce request, an I/O thread writes the message batch to the end of the appropriate partition log segment, normally through the operating system’s page cache. Kafka can then wait for in-sync followers before returning the producer response; the I/O thread does not itself guarantee durable disk persistence. section 8.2.1 section 8.5
For a consumer fetch request, an I/O thread reads message batches rather than writing them. The data may come directly from the page cache. If no messages are available, the broker can wait for more data according to fetch.min.bytes and fetch.max.wait.ms before queuing the response. section 9.2
Configure I/O capacity around the broker’s workload:
- Set num.io.threads to match the number of disks when multiple disks are used, supporting throughput across the available storage. section 6.3.1
- Treat tuning as a production concern for brokers handling large data volumes, alongside network-thread, queued-request, and operating-system settings. section 6.3.1
- Do not confuse I/O-thread throughput with disk durability: Kafka normally relies on the operating system to flush page-cache data, while replication supplies reliability. section 8.2.1
Figure 8.3 When a broker receives a produce request (1), it’s put on the request queue (2) and later handled by the I/O threads (3) and written to the page cache (4). The operating system flushes it to disk later. Then, the message stays in purgatory (5) until all in-sync followers acknowledge the message (6). When the wait (7) is over, the response is put on the response queue (8) and sent back to the producer by one of the network threads (9).
Trace a produce request from network reception through the request queue, I/O-thread processing, page-cache storage, follower acknowledgment, and the response queue. section 8.2.1
