Guide contents

Lesson 1 of 44

Introduction: How This Course Works

This course teaches Tokio, the async runtime used by most Rust network services. It starts with what async code is and ends with runtime internals, production practice, and the questions asked in senior and lead interviews.

What you will be able to do

  • Write async Rust with async/await and explain what the compiler generates.
  • Run and control concurrent work with tasks, channels, locks, timers, and select!.
  • Build TCP, UDP, and file-based programs with Tokio's async I/O.
  • Shut services down cleanly, apply backpressure, and test time-dependent code deterministically.
  • Explain how the scheduler, the reactor, and the timer wheel work, and write futures by hand.
  • Answer runtime, concurrency, and design questions in interviews.

What the course assumes

You know the Rust language: ownership and borrowing, structs, enums, traits, generics, closures, iterators, Result and ?, Box, Rc, Arc, std::sync::Mutex, std::thread, and std::sync::mpsc. The site's Rust Programming course teaches these.

You do not need to know anything about async, futures, or Tokio. The course teaches those from the first concept.

How the course is built

  • Every lesson is a sequence of numbered examples. Each example is code followed by its exact output.
  • Examples in the earlier lessons were compiled and run against Tokio 1.x on Rust 1.94 (edition 2024), and the output shown is what the program printed. Blocks flagged rust,ignore were not run by the site's example checker; their expected output was worked out from the code and, for internals, from the Tokio source.
  • Output never depends on timing. Servers bind to port 0, and time-based examples use Tokio's paused clock or print counts and orderings.
  • A lesson uses only ideas from earlier lessons. When it must mention something that comes later, it says what it does in one sentence and links to the lesson that teaches it.
  • The course contains 27 practical projects, ordered from a countdown timer to a job-queue service. Each project is built in stages and appears in a workshop lesson after the topics it needs.

Set up a project

Create a project and add Tokio and the crates used in later lessons:

Terminal
cargo new tokio-course
cd tokio-course
cargo add tokio --features full

The full feature turns on every Tokio component. Your First Tokio Program explains the individual features. Later lessons add tokio-util, tokio-stream, bytes, futures, tracing, and a few other crates; each lesson names the crates it needs.

Example 1: Check your setup

Put this in src/main.rs and run cargo run. The #[tokio::main] line starts the runtime; Your First Tokio Program explains it.

Rust
#[tokio::main]
async fn main() {
    let message = async { "Tokio is running" }.await;
    println!("{message}");
}
Output
Tokio is running

Lessons

Section Lessons
Getting Started This introduction, threads vs async and where Tokio fits, your first Tokio program
Async Foundations Futures and async/await, polling and wakers, a tiny executor
Tasks and Time Spawning, join!, cancellation and panics, select!, blocking work, time, Workshop 1
Shared State and Channels Mutex and RwLock, Semaphore, Notify, mpsc, oneshot, broadcast, watch, Workshop 2
Async I/O AsyncRead and AsyncWrite, TCP, UDP and Unix sockets, files, processes and signals, Workshop 3
Concurrency Patterns JoinSet, graceful shutdown, backpressure, actors and worker pools, Workshop 4
Streams and Protocols Streams, Bytes and framing, codecs, Workshop 5
Runtime Internals Writing futures by hand, runtime flavors and the builder, the scheduler, the reactor and timer wheel, task layout, Workshop 6
Production Tokio Error handling, tracing, testing, performance, pitfalls, the ecosystem, Workshop 7
Interview Practice Concept questions, internals and production questions, coding problems, design and scenario questions

Practical projects

Workshop Projects
1. Tasks and Time Countdown timers, parallel checksums, retry with backoff, heartbeat monitor
2. Shared State and Channels Rate-limited job runner, processing pipeline, worker pool, bank account actor, live configuration reload
3. Async I/O TCP echo server, key-value server, chat room, minimal HTTP server, process runner and file follower
4. Concurrency Patterns Bounded crawler, graceful-shutdown server, cron-style scheduler, connection pool, TCP proxy, supervised actors
5. Streams and Protocols Length-delimited chat protocol, streaming ETL pipeline, mini-Redis with expiry and pub/sub
6. Runtime Internals Timeout, debounce, and retry combinators from scratch; scheduler experiment with runtime metrics
7. Production Practice Deterministic test suite, job-queue service

How to practice

Type the examples instead of pasting them. Change a value, predict the output, then run it. After each workshop, extend one project with a feature the lesson did not include.

Interview points

  • State the prerequisites for async Rust: ownership, traits, closures, Arc, Mutex, and threads.
  • Explain what the course covers in order: futures, tasks, channels, I/O, patterns, streams, runtime internals, production practice.
  • Name the crates used later: tokio, tokio-util, tokio-stream, bytes, futures, tracing.

Summary

  • The course teaches Tokio from async/await to scheduler internals in 44 lessons and 27 projects.
  • Each lesson uses only ideas from earlier lessons.
  • cargo add tokio --features full is enough to run every example that uses Tokio alone.
  • Blocks flagged rust,ignore are not machine-checked.