Concurrency is not parallelism

July 16, 2019

“Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once”
- Rob Pike

Concurrency Parallelism
Interruptability Independentability
Separation of tasks to provide interleaved execution Simultaneous execution of multiple pieces of work in order to increase speed
A way of structuring your programs: it has to do with how programs are written A way of making your programs go faster; it has to do with how programs are run
You decide to learn Go!
You start watching a video tutorial, you need to pause the video, apply what been said in code then continue watching
You’re a professional Go programmer…
…and you enjoy listening to calm music while coding

Concurrency             Concurrency + parallelism
(Single-Core CPU)       (Multi-Core CPU)
 ___                     ___ ___
|th1|                   |th1|th2|
|   |                   |   |___|
|___|___                |   |___
    |th2|               |___|th2|
 ___|___|                ___|___|
|th1|                   |th1|
|___|___                |   |___
    |th2|               |   |th2|

Move a pile of obsolete language manuals to the incinerator…

This is a concurrent design.

We can parallelize on the other axis…

  • the concurrent design makes it easy - eight gophers, all busy!

Or maybe no parallelization at all…

Keep in mind, even if only one gopher is active at a time (zero parallelism), it’s still a correct and concurrent solution.