Tokio RuntimeMetrics: what to monitor

⚓ Rust    📅 2026-03-09    👤 surdeus    👁️ 1      

surdeus

I'd like to get an alert from my service when Tokio's async worker thread pool is overloaded---that is, when it has runnable tasks that aren't being polled for a significant amount of time, simply because all Tokio's worker threads are 100% busy.

Can I use RuntimeMetrics to detect this? I'm sure num_alive_tasks is not what I want, since it includes tasks that are currently blocked on I/O, or sleeping, and thus not in need of CPU time. Do global_queue_depth and worker_local_queue_depth count specifically runnable tasks, i.e. those whose futures Tokio plans to poll ASAP?

1 post - 1 participant

Read full topic

🏷️ Rust_feed