Skip to content

I/O multiplexing

Category: Scheduling · Status: stub · Lessons: chapter 06, Async (planned)

One line: Asking the operating system to watch many sockets or file descriptors at once and report which are ready, so that one thread can serve thousands of connections.

Also called: epoll, kqueue, IOCP, select(2), poll(2).

How it connects

flowchart LR
  n_async_runtime["Async runtime (executor and reactor)"]
  n_event_loop["Event loop"]
  n_io_multiplexing["I/O multiplexing"]
  n_async_runtime -->|uses| n_io_multiplexing
  n_event_loop -->|uses| n_io_multiplexing
  classDef center stroke-width:3px
  class n_io_multiplexing center
  classDef outside stroke-dasharray: 4 3
  class n_async_runtime,n_event_loop outside

In each language

Rust Not in the standard library; the mio crate's Poll is backed by epoll, kqueue or IOCP, depending on the OS
C POSIX poll and select
Java Selector over non-blocking channels
Python selectors, whose DefaultSelector picks the most efficient mechanism on the platform
The operating system epoll(7) on Linux, poll(2) everywhere; Windows I/O completion ports ↗ queue a packet when an I/O operation completes

Where to read more