Back to all posts
CONCURRENCY PATTERNS • 13 MIN READ • November 18, 2024

Building Async Actor Systems in Pure Rust Without Heavy Frameworks

Constructing composable, backpressure-aware actors using Tokio mpsc bounded channels, CancellationToken, and graceful shutdown loops.

Prabhat Sharma Principal Systems Architect

An Actor Is Just a Task and a Mailbox

You do not need a framework to get actors. A bounded tokio::sync::mpsc channel is the mailbox, a spawned task is the actor, and a select! loop over the receiver plus a CancellationToken gives you graceful shutdown and backpressure for free.

actor.rs
rust
loop {    tokio::select! {        biased;        _ = token.cancelled() => break,        Some(msg) = rx.recv() => handle(msg).await,    }}

Backpressure by Construction

Because the channel is bounded, a slow actor naturally applies backpressure to its senders — send().await suspends until capacity frees up. No unbounded queue, no silent memory blowup under load.