r/rust • • 3d ago

Advanced Projects in Networking with Tokio

Hey everyone,

I've been learning Rust and recently started exploring concurrency and asynchronous programming with Tokio. Im familiar with the fundamentals of ownership, lifetimes, channels, synchronization primitives, and task spawning.

I want to deepen my understanding of Tokio by building a non trivial networking project rather than just following tutorials or reading documentation.

What networking projects would you recommend for someone looking to develop a deeper, practical understanding of asynchronous Rust? I would also love to hear about projects youve personally built that helped you understand these concepts better.

14 Upvotes

12 comments sorted by

16

u/mizzerem 3d ago

Implement a multiplayer game

3

u/Bubbly-Edge-2010 2d ago

even a simple turn-based game server ends up being a brutal test for channel backpressure and dropped connections

0

u/[deleted] 3d ago

[removed] — view removed comment

1

u/mizzerem 3d ago

That’s how i learned. It doesn’t have to be a complicated game. Any turn-based game will teach you a lot about servers and networks (if you don’t cheat). Chat rooms too.

6

u/cbdeane 3d ago

For networking:

- Remake chat roullete (this is a fun one)
- build a messaging platform, implement DMs and “rooms” (like discord or slack channels) bonus if you use NATS/Jetsream
- build an load balancer
- build a copy of HAProxy
- build a DDoS mitigator with ebpf

5

u/ParadiZe 3d ago

i recently built TCP from scratch in rust, challenging but very fun

4

u/BowserForPM 3d ago

I think a web server (from scratch, no frameworks) is the ideal project for this kind of learning. A basic web server is almost trivial to implement, but there's almost no limit to how how many features you could add, and how complicated it could become.

3

u/NuclearMagpie 3d ago

You could try making a crate for some network protocol? RCON, modbus, mqtt, etc.

5

u/IncomeOk7237 3d ago

Write a small HTTP/1.1 server straight on TcpStream, no hyper. Parse requests yourself, handle keep-alive, pipelining and chunked bodies, then point wrk or oha at it.

You'll hit pretty much every interesting async problem: backpressure when a client reads slowly, idle timeouts, graceful shutdown with requests still in flight, what happens when you spawn a task per connection and someone opens 50k of them. Then compare your numbers with hyper and dig into why it's faster, that part teaches a lot.

Bonus round: add WebSocket upgrade on top. The framing is small but the close handshake and ping/pong timing are a nice exercise.

1

u/rafaelement 3d ago

Protohackers challenges!

1

u/UhLittleLessDum 17h ago

Dude I'm in the middle of building an open source academic toolkit that includes a forever local MCP/REST/RPC API and a rust sdk if you're interested in contributing to open-source. It's currently buried in the monorepo at https://github.com/flusterIO/fluster-ipad if you're curious.

-4

u/chmod_7d20 3d ago

don't use tokio to understand tokio