Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsApr 12, 2026·2 min de lecture

Tokio — Async Runtime for Reliable Rust Applications

Tokio is a runtime for writing reliable asynchronous applications with Rust. Provides async I/O, networking, scheduling, and timers. The foundation of most async Rust projects including Axum, Hyper, Tonic, and the broader Rust web ecosystem.

Introduction

Tokio is the most popular asynchronous runtime for Rust. It provides building blocks for writing network applications: async I/O, timers, a multi-threaded work-stealing scheduler, channels, and synchronization primitives. Nearly every async Rust project depends on Tokio — it is the foundation of Axum, Hyper, Tonic (gRPC), reqwest, and more.

What Tokio Does

  • Multi-threaded scheduler — work-stealing for parallel async tasks
  • Async I/O — TCP, UDP, Unix sockets, named pipes
  • Timers — sleep, interval, timeout
  • Channels — mpsc, oneshot, broadcast, watch
  • Sync primitives — Mutex, RwLock, Semaphore, Notify (async-aware)
  • Task spawning — lightweight green threads
  • Runtime — configurable (multi-thread or current-thread)
  • Tracing — integrated with tokio-console for debugging

Architecture

Work-stealing scheduler: multiple OS threads each maintain a local task queue. When idle, a thread steals tasks from others. Each task is a Future that the runtime polls. I/O is backed by epoll (Linux), kqueue (macOS), or IOCP (Windows) via the mio crate.

Comparison

Runtime Multi-thread I/O
Tokio Work-stealing mio
async-std Work-stealing async-io
smol Work-stealing async-io
monoio Thread-per-core io_uring

FAQ

Q: When to use Tokio? A: Any Rust project that needs async I/O — web server, gRPC, database clients, concurrent requests in CLI tools.

Q: Compared to async-std? A: Tokio has the largest ecosystem, the most active maintenance, and the best performance. async-std more closely mirrors the std API but has a smaller community.

Sources

Discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires