Skip to content

rust.unbounded_concurrency

Scalability High

Detects spawning tasks without concurrency limits that can exhaust system resources.

Unbounded concurrency:

  • Exhausts memory — Too many tasks consume RAM
  • Starves CPU — Excessive context switching
  • Causes cascading failures — System-wide instability
// ❌ Before (unbounded task spawning)
for item in items {
tokio::spawn(process(item));
}
// ✅ After (with concurrency limit)
use futures::stream::StreamExt;
futures::stream::iter(items)
.map(|item| tokio::spawn(process(item)))
.buffer_unordered(100) // Limit concurrent tasks
.collect::<Vec<_>>()
.await;
  • Unbounded task spawning in loops
  • Missing semaphore guards
  • No concurrency limits on parallel work

Unfault can add concurrency limiting with buffer_unordered or semaphores.