Concurrency Models, Scheduling and Scaling Laws
Know when concurrency helps, what each execution model costs, and how scaling laws and queueing limit the gains from adding threads, cores or nodes.
Key points
- 1
Concurrency is overlapping progress; parallelism is simultaneous execution. One core can be concurrent but never parallel.
- 2
Processes isolate memory and failures; threads share an address space and are cheaper; coroutines and goroutines switch in user space and cost a few KB each.
- 3
Amdahl's law: speedup = 1 / ((1 − p) + p/n), capped at 1 / (1 − p). Gustafson's law covers problems that grow with the machine.
- 4
The Universal Scalability Law adds contention (σ, a plateau) and coherency (κ, retrograde scaling) to explain why throughput can fall as nodes are added.
- 5
Little's law L = λW sizes concurrency: pools, connections and in-flight requests. For I/O-bound pools, threads ≈ cores × (1 + wait/compute).
- 6
CPU-bound work wants about one worker per core; extra threads only add context switches and cache thrashing.
- 7
M:N schedulers (Go G-M-P, Java virtual threads, BEAM) multiplex many lightweight tasks onto few OS threads and hand off around blocking calls.
Common traps
Amdahl's law never predicts a slowdown; falling throughput comes from overheads such as coherency, switching or contention.
SMT siblings share one core, so 8 logical CPUs on 4 cores do not double CPU-bound throughput.
Cooperative schedulers (asyncio, pre-1.14 Go loops) stall every task when one task runs without yielding.
Read the source
Test yourself on Concurrency Models, Scheduling and Scaling Laws
Ten questions, with the answer and explanation after each one.