Concurrency is not parallelism


Do not confuse concurrency with parallelism. The Go language blog has an excellent post:

In programming, concurrency is the composition of independently executing processes, while parallelism is the simultaneous execution of (possibly related) computations. Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once.

In other words, concurrency refers to a single program that executes asynchronous processes regardless whether it is single-threaded or multi-threaded and regardless whether it runs on a single-core or multi-core CPU Concurrency is not about threads or CPU. It is all about whether you execute processes in an asynchronous fashion. In the case of Node.js, since it is using a single-threaded event loop, you are advised not to block the event loop for input/output operations or network calls. In the case of Go language, concurrency can be
achieved using its built-in high-level constructs called goroutines and channels. Go multiplexes user-level goroutines onto OS-level threads.

But here is the difference between concurrency in Node and Go.

With Node, you are manually managing concurrency through the use of callbacks, promises, async library or what have you. With Go, the Go runtime automatically manages concurrency so you can write blocking operations without callback as long as you put it in a goroutine and optionally use a channel for its output if need be.

Either way, asynchronous programming is easier to reason about than thinking in terms of multithreading.

On the other hand, parallelism is about executing multiple identical processes

  • regardless whether it runs on a single computer with multi-core CPU or multiple computers with single/multi-core CPU
  • regardless whether it is concurrent process or not.

Of course, parallelism does not apply to a single computer with a single-core CPU but it does apply in the context of multiple computers regardless of number of CPU as long as the above-mentioned condition is met.

Parallelism is best described with N-tier architecture where programs/applications are deployed in parallel at the application/logic tier to achieve high throughput and high availability.

In short, concurrency is about asynchronous processes while parallelism is about executing multiple identical processes simultaneously.


Subjectivity aside, leave a reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s