/iou-http

An io_uring based HTTP server written in Rust

Primary LanguageRustMIT LicenseMIT

iou-http

This is a toy async runtime and minimal HTTP server written in Rust as a project to learn about async runtimes and io-uring.

The project was written by Peter Malmgren and Evan Schwartz while participating in the Recurse Center's programmer retreat.

Design

The Runtime consists of the:

  • Executor, which runs Futures from a queue of pending Tasks
  • Reactor, which submits I/O operations to the kernel using io-uring and reacts to completion events

io-uring uses two ring buffers shared between the userspace code and the kernel in order to submit I/O calls and handle the results. The Runtime is single-threaded because the ring buffers cannot be safely modified by multiple threads without wrapping them in a mutex, which would degrade performance.

While the runtime is single-threaded, the HTTP Server is multi-threaded. It uses one thread (with its own runtime and io-uring buffers) to accept incoming TCP connections and it uses the other threads (also with their own runtimes) to handle requests on those connections.

Acknowledgements

This project takes inspiration from tokio-uring's design document and the Rust Async Book's chapter on building an executor. The project also uses the io-uring crate's Rust bindings for io-uring.