Skip to main content

Crate tako_rs_server_pt

Crate tako_rs_server_pt 

Source
Expand description

Thread-per-core HTTP server bootstrap for the Tako framework.

Spawns N OS threads (one per CPU by default), each running its own tokio current_thread runtime + tokio::task::LocalSet. Connections are distributed across workers at the kernel level via SO_REUSEPORT. Tasks never migrate between threads, eliminating tokio’s work-stealing coordination on the hot path and improving cache locality (especially with the affinity feature which pins each worker to a specific core).

Two entry points:

  • serve_per_thread — uses the existing thread-safe tako_rs_core::router::Router from tako-core. Drop-in alternative to tako::serve; no API changes.
  • serve_per_thread_compio (under the compio feature) — same SO_REUSEPORT bootstrap but each worker runs a compio runtime (io_uring on Linux, IOCP on Windows, kqueue on macOS).

Structs§

PerThreadConfig
Configuration for serve_per_thread (and the compio variant when enabled).
PerThreadShutdown
Shutdown coordinator shared by every worker spawned via spawn_per_thread (and friends). Workers select! against Self::notified in their accept loop, so triggering PerThreadShutdown::trigger cleanly exits each worker’s loop { accept } instead of leaking the OS thread on shutdown.

Functions§

serve_per_thread
Starts a thread-per-core HTTP server with the given router.
serve_per_thread_compiocompio
Starts a thread-per-core HTTP server with the compio runtime.
spawn_per_thread
Spawn the worker threads and return both the join handles and a PerThreadShutdown that the caller can use to signal a clean stop.