Skip to content
fbull.de
Go back

Learning Tokio Through Projects: From Echo Servers to Distributed Systems

I want to get more comfortable with Tokio, Rust’s async runtime. Learning async Rust can feel intimidating, so I decided to take it step by step.

This is not a universal learning path. It is my personal plan, and I will update the list as I make progress and write dedicated articles for each project.


Beginner Level

  1. Async Echo Server
    Build a TCP server that accepts connections and echoes messages back.
    Concepts: TcpListener, TcpStream, spawning tasks with tokio::spawn.

  2. Chat Server (Multi-client Echo)
    Extend the echo server to broadcast messages from one client to all connected clients.
    Concepts: Using tokio::sync::broadcast channels for fan-out messaging, managing client lifetimes, handling dropped receivers.

  3. Simple HTTP Server
    Parse basic HTTP requests and return static responses, for example always return “Hello World”.
    Concepts: Async I/O parsing, handling request and response framing.


Intermediate Level

  1. Async File Downloader
    Given a URL, download the file asynchronously using reqwest with the Tokio runtime.
    Concepts: Async file I/O with tokio::fs, streaming large responses.

  2. Key-Value Store Server
    Create a TCP server where clients can SET and GET keys, similar to a toy Redis.
    Concepts: Parsing simple text protocols, storing state in memory, tokio::select!.

  3. WebSocket Chat Application
    Use tokio-tungstenite to build a chat app over WebSockets where clients can join rooms.
    Concepts: Higher-level protocols over TCP, managing multiple async streams.


Advanced Level

  1. Proxy Server (TCP Forwarder)
    Build a transparent TCP proxy that forwards traffic between client and target server.
    Concepts: Bidirectional stream handling, tokio::io::copy_bidirectional.

  2. Async DNS Resolver
    Implement a minimal DNS client that sends UDP queries and parses responses.
    Concepts: Working with tokio::net::UdpSocket, binary protocol parsing.

  3. Task Scheduler / Job Runner
    Write a daemon that accepts jobs, for example shell commands, over TCP and runs them concurrently.
    Concepts: Process management with tokio::process, cancellation with tokio::time, graceful shutdown.

  4. Miniature Distributed Key-Value Store
    Extend your KV store into a cluster where nodes replicate data across the network.
    Concepts: Peer-to-peer communication, Raft-like consensus at a basic level, handling network partitions.


Closing Thoughts

This list is my roadmap for learning Tokio. It might change as I progress, and I will keep updating it with links and refinements. If you are also learning async Rust, you might find some useful ideas here.



Previous Post
Building My First Async Echo Server with Tokio
Next Post
AI as an enzyme for productivity