Concurrency & Symptom Finder
“Threads, async or processes?” and “why is my process slow, hung or dying?” — answer the questions and get a recommendation with the reasons the alternatives were rejected.
The OS offers three ways to do several things at once — threads that share memory, an event loop that never waits, and processes that share nothing. The right one depends on whether the work is CPU-bound or I/O-bound, which runtime you are in, how much state must be shared, what must survive a crash, and how many things are in flight at once.
Step 1
Where does the time go: computing, or waiting?
Run it once and look at top: a CPU-bound task pins a core; an I/O-bound task shows low CPU while the wall clock ticks. Waiting on the network, disk, a database or a user is I/O.