Start with the idea
Async executors run many tasks on few threads and rely on each task yielding at an await. A synchronous file read, a long computation, or a std Mutex held across an await occupies its thread and starves every task queued behind it. The fixes are spawn_blocking, a dedicated pool, or an async-aware version of the call.
An async function does not turn every operation inside it into nonblocking work. An executor polls tasks on worker threads. If a task calls a synchronous sleep or performs a long CPU loop, that worker cannot poll other ready tasks until the call returns or the code yields. Even a short operation can matter at high concurrency if it appears in every request. The right diagnosis is to measure the delay of unrelated tasks while the suspicious operation runs.
A synchronous mutex is not automatically wrong in async code.
Keep learning, for free
The rest of this lesson is waiting for you.
Create a free account to read the complete explanation, see the infographic, explore the code, and try the exercises. All 742 lessons and algorithm steps are included.
No payment details. Your account opens the complete Academy.