Apache Kafka Streaming (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
Zero-Copy Architecture Deep Dive: Linux `sendfile()` syscall, DMA transfer, and kernel page cache direct routing.
senior LevelMost AskedRoutingSystem Design
In Simple Words:
Traditional file transfer requires 4 context switches and 3 data copies between kernel memory and user space.
Kafka's Zero-Copy Optimization with sendfile():
- Kafka instructs the Linux kernel to transfer data directly from the OS Page Cache to the NIC Network Socket Buffer via Direct Memory Access (DMA).
- Data never copies into JVM user memory.
- Results in near-zero CPU utilization, near-zero garbage collection pressure, and bus-saturating network transfer speeds.