Concurrency vs parallelism
Concurrency structures work; parallelism runs work at the same time. Do not treat them as interchangeable.
Canonical guidance
- concurrency is about composition and coordination
- parallelism is about simultaneous execution
- a concurrent design may run on one core; a parallel design may still be poorly structured
Use when
- deciding whether goroutines are warranted
- reviewing latency-hiding or pipeline designs
- separating design goals from performance goals
Avoid
- using goroutines as a synonym for optimization
- arguing about scheduler settings before clarifying ownership and cancellation
- adding concurrency to code that is simpler sequentially
Preferred pattern
- first decide the ownership and waiting model, then measure whether parallel execution helps
Anti-pattern
- “make it concurrent” as the whole design rationale
Explanation: This is tempting because goroutines are cheap, but cheap concurrency is still complexity if the problem does not need coordination.
Why
- good concurrent structure and good parallel execution are related but different decisions
Related pages
Sources
- Concurrency is not parallelism - Rob Pike