Click here to Skip to main content
13,898,599 members
Click here to Skip to main content
Add your own
alternative version

Stats

6.5K views
9 bookmarked
Posted 20 Nov 2018
Licenced CPOL

Concurrency vs Parallelism

, 20 Nov 2018
Rate this:
Please Sign up or sign in to vote.
This article will explain the difference between concurrency and parallelism. Concurrency vs parallelism has been a debated topic for a long time.

Table of Contents

Actual Parallelism Vs Feel of Parallelism

Technical vocabulary in IT industry is sometimes very confusing and “Concurrency” and “Parallelism” are some of them. Many developers think “Concurrency and parallelism means executing at the same time” which is right 50%, but with one big difference:

  • Concurrency gives you a feel of parallelism and parallelism as the name implies is actual parallelism.

Feel of parallelism means you execute multiple tasks on the same core and the core switches context between tasks and serves them. You can also term this has time slicing / overlapping time period because your single core is just dedicating some time to one task and then some time to other.

Actual parallelism means you execute multiple tasks on multiple cores parallely.

Note: “Concurrency is a broader term and Parallelism is a subset of it”.

Mapping to the real world, the left image depicts parallelism the right image depicts concurrency.

Why a Feel of Parallelism and Why Not Actual?

In order to achieve actual parallelism, we need dedicated cores, separate memory and so on.
We need MORE RESOURCES.

Let’s say we want to show a progress bar for some task completed. Now we really do not want to have separate cores allocated to display the progress.

We do not want PERFORMANCE here, we want that physiologically the end user feels both tasks are happening simultaneously.

We want to just beat the human eye capability of 100 FPS and give an illusion of parallelism without stressing our computer resources. But let’s say we want to process big Excel files with a million records, then yes we would love to have actual parallelism to achieve performance.

Concurrency Is About Design, Parallelism Is About Hardware

In order to achieve concurrency, we need to compose our application logic independently. For instance, let’s say you want to process employee data where you want to increment the salary by x% and bonus by x%.

So you can decompose the application into logical units by following different designs:

Design 1

  • Divide data into 50% size each.
  • Process each 50% as separate unit.

Design 2

  • Process bonus calculation as separate unit.
  • Process salary calculation as separate unit.

Design 3

  • Divide data into 50% size each.
  • For every 50% data process bonus calculation separately and salary calculation separately.

There can be many such designs and combinations. So when you say your application is supporting concurrency, your application should be composed into small independent units.

Now you take these units and run on one core (Concurrency) or you run on multiple cores (Parallelism). So concurrency is about design while on parallelism, we talk more from the hardware perspective, 2 core, 3 cores and so on.

If you try to run every concurrent code as parallel, you have resource starvation unnecessarily. So ask yourself if you want an illusion (concurrent) or if you want performance (parallel).

Concluding

  Concurrency Parallelism
Basic definition Executing multiple tasks on the same core using overlapping or time slicing. Executing multiple tasks on different core.
Goal Feeling of parallelism without stressing out resources. Actual parallelism for performance.
Perspective Software design: Composition of independently executing computations in a co-operative fashion. Hardware: Executing computation parallel.
Resource utilization Light Heavy
  • Parallelism is a subset of concurrency.
  • Concurrency enables parallelism.
  • Concurrency is more about software design while parallelism is more about hardware.
  • Concurrency gives an illusion of parallelism while parallelism is about performance.
  • Concurrency just needs one core while parallelism needs at least 2 cores.

Further Reading

Concurrency and Parallelism video

Here we have something more in video based learning on Concurrency and Parallelism topic do view following 20+ minutes sit back, relax and enjoy full video: -

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author


You may also be interested in...

Comments and Discussions

 
QuestionA more nuanced view Pin
asiwel1-Dec-18 19:34
professionalasiwel1-Dec-18 19:34 
GeneralMy vote of 3 Pin
tbayart24-Nov-18 9:25
membertbayart24-Nov-18 9:25 
GeneralRe: My vote of 3 Pin
wmjordan25-Nov-18 19:56
professionalwmjordan25-Nov-18 19:56 
GeneralRe: My vote of 3 Pin
Shivprasad koirala1-Dec-18 16:45
memberShivprasad koirala1-Dec-18 16:45 
GeneralRe: My vote of 3 Pin
Shivprasad koirala1-Dec-18 16:44
memberShivprasad koirala1-Dec-18 16:44 
QuestionDisagree Pin
asiwel22-Nov-18 7:27
professionalasiwel22-Nov-18 7:27 
AnswerRe: Disagree Pin
David Sherwood22-Nov-18 13:26
memberDavid Sherwood22-Nov-18 13:26 
AnswerRe: Disagree Pin
David Sherwood22-Nov-18 13:30
memberDavid Sherwood22-Nov-18 13:30 
GeneralGood follow-up discussion Pin
asiwel22-Nov-18 16:31
professionalasiwel22-Nov-18 16:31 
GeneralRe: Good follow-up discussion Pin
Shivprasad koirala1-Dec-18 17:04
memberShivprasad koirala1-Dec-18 17:04 
AnswerRe: Disagree Pin
Shivprasad koirala1-Dec-18 16:31
memberShivprasad koirala1-Dec-18 16:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190306.1 | Last Updated 21 Nov 2018
Article Copyright 2018 by Shivprasad koirala
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid