Actors for Rust, on solid ground.
tellus gives you typed actors as state machines, supervision trees and a death watch you can reason about. Add event sourcing and a cluster when you need them.
GroupMessage::Record {
device_name,
degrees,
} => {
let device = devices
.entry(device_name)
.or_insert_with(|| context.spawn(Device));
device.tell(DeviceMessage::Record(degrees));
Ok(Control::Continue(devices))
}A message handler is a plain function.
Carl Hewitt defined an actor by what it may do in response to a message. A tellus receive does exactly that and nothing more. It runs to completion, so an actor is never halfway through a message with its state in limbo.
When an actor needs to wait for something, the result arrives as another message, so actor code never awaits. Even event sourcing works this way: the handler returns the events as data, and tellus does the I/O.
Why tellus handlers are synchronous →Know when an actor is gone, and know you have heard everything it said.
Receiving Terminated proves you have seen every message that actor will ever deliver to you.
Watch any actor with context.watch(&actor). When it terminates, you get a signal in your ordinary mailbox, ordered behind every message the actor delivered to you. Each of its messages arrived before the signal or was dropped as a dead letter.
So you can gather results from workers without counting replies, timeouts or extra acknowledgments: when the last worker's signal arrives, you have every result the workers delivered. And unwatch means what it says, even if the signal is already waiting in your mailbox.
Terminated.Ordered and exact
The signal is ordered behind every delivered message and proves that the actor's destructors have run. It is delivered even when a bounded mailbox is full.
Same API, two tiers
A real termination keeps the full local contract over the wire. If the actor's node is downed instead, the synthesized signal guarantees that no message from that actor is delivered on the watcher's node again.
No stale signals
After unwatch returns, you never receive a terminated signal for that actor, even if one was already enqueued, unless you stash it yourself.
Let it crash, then restart it calmly.
Actors form a tree. When init or receive returns an error or panics, the actor's supervision strategy decides what happens. Stop terminates the actor. Restart stops its children and runs init again for a fresh state; the actor keeps its address and mailbox.
Restarts back off exponentially between min and max. More than max_restarts consecutive failures stop the actor, and running for reset_after without failure starts the count afresh. Stopping always goes bottom-up: children first, then the parent.
mailbox_capacity = { bounded = 100 }
[supervision_strategy.restart]
max_restarts = 3
reset_after = "30s"
backoff = { min = "250ms", max = "4s" }persistencePersist the events, replay the state.
Implement EventSourced instead of Actor. Your handler validates a command and returns an Effect naming the events it causes. tellus appends them to the store, and only then folds them into the state. After a crash, replay rebuilds the state from the events, optionally shortcut by a snapshot.
Conditional appends fence concurrent incarnations, and manifests version your event schemas. A contract test suite checks any store backend. PostgreSQL ships today in tellus-persistence-postgres; an in-memory store and TestContext let you test without a database.
fn handle(
&self,
_: &ActorContext<Self::Command>,
incoming: Incoming<Self::Command>,
_: &Self::State,
) -> Result<Effect<Self>, Self::Error> {
let Incoming::Message(command) = incoming else {
unreachable!("the device watches no actor, hence never gets a terminated signal")
};
match command {
Command::Record(degrees) if degrees.is_nan() => Err(InvalidReading),
Command::Record(degrees) => Ok(Effect::persist(Recorded(degrees))),
Command::Read(reply_to) => {
Ok(Effect::none().then(move |last_reading| reply_to.reply(*last_reading)))
}
}
}
fn apply(&self, _: Self::State, Recorded(degrees): Self::Event) -> Self::State {
Some(degrees)
}- handleValidates the command and returns an
Effect. - appendtellus appends the events to the
EventStore, conditional on the stream's head. - applyOnly durable events are folded into the state, the same way on replay as live.
- thenSide effects such as the reply run once the events are durable.
clusterSame API, many nodes.
With the cluster feature, ActorRef is serializable, so a message can carry a reference to an actor on any node. You tell, ask and watch remote actors through the same API as local ones. Nodes find each other through seed discovery, gossip their membership, and agree on who is gone. The clustered actors tutorial spreads the device manager over three nodes.
Five nodes under continuous crashes, departures and partitions, with a verifier checking convergence, cross-node messaging and the receptionist in every quiet window. Run it yourself.
QUIC with mutual TLS
Transport over quinn, with every node authenticated by the cluster's own certificate authority, and messages in order per sender and recipient across the wire.
Address-bound certificates
A node is admitted only at an address its certificate covers, so an authenticated node cannot claim another member's address.
Seed discovery
Fixed seeds, DNS SRV or A/AAAA records, or Kubernetes pods by label selector.
Gossiped membership
The member list is a state-based CRDT, so duplicated, reordered or crossed gossip cannot corrupt it.
Failure detection and downing
Phi accrual detection and a pluggable downing provider; KeepMajority by default.
Graceful leave
A node that stops announces its departure and drains its queues, so the others list it as left without detecting a failure.
Cluster identity
Every cluster has an ID, and every connection names it. A node of another cluster is refused. Two clusters never merge, and a split into two is reported.
Receptionist and pub-sub
Register actors under a key, look them up across the cluster, and publish to every subscriber of a topic.
Observable cluster state
A versioned value on every change; tellus-cluster-inspect serves it to you as server-sent events.
bootstrap:
min_nodes: 5
endpoint:
app_version: "1.0.0"
failure_detector:
phi_accrual: {}
downing_provider:
keep_majority:
after: 10sseeds:
k8s:
label_selector: app=tellus
port:
number: 7878Measured fairly, published openly.
We benchmark tellus against kameo and ractor, two actively maintained actor frameworks that also run on a plain Tokio runtime. Every framework does the same work, and the competitors run in their fastest configuration, not their defaults.
flood100,000 messages to a single counting actor.ping_pong1,000 rounds between pairs of actors, one pair and eight pairs.fan_out100,000 messages round-robin to 8 and to 32 workers.Speed is one difference among many. Rust actor frameworks compared sets tellus next to actix, kameo and ractor, feature by feature.
We also watch our own hot path. hotpath profiles every pull request against main, comparing instruction counts and allocations per function, and its check fails when sending a message or replaying events starts to allocate.
- One run, one machine, back to back. Numbers are only compared within a single run.
- Unbounded mailboxes everywhere, so no framework drops or backpressures messages the others do not.
- Non-blocking fire-and-forget sends only, no awaited sends and no request-response.
- Identical timing boundaries. Spawning happens outside the measurement; sending and termination inside it.
- The same Tokio runtime with the same configuration for all three.
- Competitors tuned for speed. Their per-message tracing is switched off, which makes kameo 12.5% and ractor 21% faster on
flood. - Termination checks correctness. A lost message makes a benchmark hang rather than finish early.
The thinking behind tellus.
Heiko Seeberger explains the design decisions behind tellus in depth on his blog.
All posts tagged tellus →- Where your stack lives can move a benchmark by 50%
- Rolling upgrades in tellus: old code cannot learn a new shape
- tellus 0.6: stashing, rolling upgrades and a faster cluster
- Breaking a Rust actor cluster on purpose, and what it taught us
- tellus 0.5: the same ActorRef, across machines
- Why you should use a bounded mailbox
- Why tellus message handlers are synchronous
- tellus 0.2: event sourcing for actors
- tellus, episode 3: one queue for messages and signals
- tellus, episode 4: terminating a tree, bottom-up
- tellus, episode 2: an actor is a state machine
- tellus, episode 1: actors for Rust, on solid ground
Start digging.
Add tellus, Tokio and anyhow to your project, then work through the getting started tutorial. Its last three steps also use thiserror and tracing-subscriber. Each step is a complete program and builds on the previous one.
cargo add anyhow
cargo add tokio --features macros,rt-multi-thread
cargo add tellus- Hello, tellusOne actor handles one message and stops.
- A device actorState as a value,
tellwithout waiting,askwith a timeout. - A group of devicesChild actors spawned on demand, stopped bottom-up.
- Watching devicesLearn when an actor is gone, after all of its messages.
- Asking all devicesA query actor per request that cannot hang.
- When devices failRestart with backoff, and stop for good.
- A device managerOne more level on top, after the IoT example of Apache Pekko.
- Stale readingsA timer forgets old readings, and an actor opts into timers by its type.