Difference between Concurrency and Parallelism

Aksel Arzuman
3 min readSep 23, 2020

Concurrency pattern is so popular these days and if you have dived deep into learning Go, you must have seen dozens of articles about how Go has powerful support for concurrency and how it is easy to implement.

My initial motivation about learning Go was like everyone else, to get the power of concurrency! Imagine someone telling you that you can achieve more by less effort and less resources, I believe you would be impressed too.

If there’s one thing most people know about Go, is that it is designed for concurrency. (Go Blog)

During my learning period of concurrency in Go, I have read lots of articles about how concurrency differs from parallelism. The explanation of them are simple, however, the difference between them might be a little hard to imagine.

Concurrency is about dealing with lots of things at once.
Parallelism is about doing lots of things at once. (Go Blog)

As you noticed, changing a word, changes everything.

Concurrency

Concurrency is dealing multiple tasks at the same time with a single core but those tasks are not running at the same time.

Consider having 6 separate tasks. In concurrency, the application might finish 10% of task 1 and move to task 4, finish it and come back to task 1 again. All tasks will be finished executing at the end as expected. The decision of which task to run is on CPU.

Parallelism

Parallelism is executing multiple tasks at the same time with multiple cores.

Let’s take the above example and change it a little bit. Assume you have 6 cores, meaning, you can assign each core to a task and get the executions done. With parallelism, the application can finish its’ tasks in a shorter period of time but requires more resources.

Do you still find it difficult to find the difference between them? Well, even if you don’t, I do! Let’s have a real world example.

Example 1

Let’s assume you want your house to be cleaned and the cleaner should clean the floor, the windows and the tables. Cleaner might clean a rooms’ windows, then the tables and might move to another room and clean its’ tables. It does not matter for you because at the end the all of the rooms will be cleaned with your expectations. This is an example for concurrency.

However, you could have called multiple cleaners and assign separate tasks to them. One cleaner will be responsible for cleaning the tables, other will be responsible for the windows and so on. Because cleaners will work separately, the cleaning will be done in a shorter period of time but it is more expensive than calling a cleaner. And this is parallelism.

Example 2

You have just established a startup and you do not have much money to burn. You hired a highly skilled developer to launch your application. He/she will be responsible for developing a web app, an IOS app and an Android application. As you already know, he/she will need to develop an API and CI/CI pipeline to them. Therefore, the developer is responsible for 5 tasks at least. He/she might start with API, then get bored and move to web, get bored and go on with IOS app and etc…

At the end of X years, you can launch your idea using concurrency pattern. I hope the developer will be alive that day. My heart is with him/her🙏

Once you launch your application and get an investment, you can start to hire experts to you apps(of course you promote your current developer to a manager role). Now each of your applications can be developed separately. And as you assumed, you used parallelism here.

If you have come this far, I hope I explained the difference well and you don’t have any questions about it. The reason why Go is so popular for concurrency will be another topic. Since then, stay safe!

References

--

--