Parallel and Distributed Computing
How sequential, parallel, and distributed computing differ, how to work out the time and speedup of each, and why adding processors eventually stops helping.
1Three ways to run a program
| Model | What happens | Clue words |
|---|---|---|
| Sequential computing | Operations are performed in order, one at a time | one processor, one step after another |
| Parallel computing | The program is broken into smaller sequential operations, some of which run at the same time | several processors (cores) in one computer |
| Distributed computing | Multiple devices are used to run a program | several computers connected by a network |
The question behind every parallel plan: can these tasks run independently, or does one need another's result first? Independent tasks can overlap. A task that needs another task's result has to wait, and that waiting limits how fast the whole job can go.
2Timing the work
Compare solutions by the time each takes to do the same task. Two rules give that time:
- A sequential solution takes as long as the sum of all its steps.
- A parallel solution takes as long as its sequential tasks plus the longest of its parallel tasks.
Here a video app does a 10-second setup, then renders three clips that do not depend on each other:
Sequential: 10 + 30 + 20 + 20 = 80 seconds. Parallel: the setup must finish before any clip starts, so it is added; the clips overlap, so only the longest counts: 10 + 30 = 40 seconds. For each step, decide: does it overlap with others (take the longest) or run alone (add it)?
3Speedup
The speedup of a parallel solution is the sequential time divided by the parallel time:
speedup = sequential time ÷ parallel time
For the clip job, 80 ÷ 40 = 2. Three processors gave a speedup of 2, not 3, for two reasons you can see in Figure 1: the setup ran in both versions, and the clips were unequal, so two processors sat idle while clip A finished. A faster parallel solution always has a speedup greater than 1. If you get 0.5, you divided the wrong way.
4Splitting tasks among processors
When there are more tasks than processors, each processor runs its tasks one after another, and the job is done when the busiest processor finishes.
| Situation | Sequential time | Best parallel time (2 processors) | Speedup |
|---|---|---|---|
| Four independent 20 s tasks | 80 s | 40 s: two tasks each | 2 |
| Tasks J 10 s, K 30 s, L 45 s, M 90 s | 175 s | 90 s: M alone; J, K, L on the other (85 s) | 1.94 |
| Steps 1 (10 s), 2 (20 s), 3 (30 s), 4 (15 s); step 2 needs step 1, step 4 needs step 3 | 75 s | 45 s: steps 1 then 2 on one (30 s), steps 3 then 4 on the other (45 s) | 1.67 |
An even split gives the ideal speedup. With uneven tasks, the longest task (M, 90 s) sets a floor no matter how the others are arranged. With dependencies, each chain of steps must run in order, and the longest chain sets the floor.
To split tasks well by hand: give the largest task to one processor, then hand each remaining task, largest first, to whichever processor has less work so far. Then check whether any swap lowers the busiest processor's total.
5The sequential limit
Every parallel solution has a parallel portion (pieces that can run at the same time) and a sequential portion (work that cannot be split: reading the input, setting up, combining the answers). More processors shrink only the parallel portion. Take a job with 100 seconds of parallel work and 20 seconds of sequential work:
| Processors | Time | Speedup |
|---|---|---|
| 1 | 100 ÷ 1 + 20 = 120 s | 1 |
| 2 | 100 ÷ 2 + 20 = 70 s | 1.71 |
| 4 | 100 ÷ 4 + 20 = 45 s | 2.67 |
| 10 | 100 ÷ 10 + 20 = 30 s | 4 |
| 100 | 100 ÷ 100 + 20 = 21 s | 5.71 |
Going from 1 to 4 processors saves 75 seconds. Going from 10 to 100 saves only 9. However many processors you add, the time stays above 20 seconds, so the speedup stays below 120 ÷ 20 = 6. This is why the efficiency of a parallel solution is still limited by its sequential portion: at some point, adding more parallel processing no longer meaningfully helps.
Sequential time is the sum of the steps. Parallel time is the sequential steps plus the longest parallel task. Speedup is sequential time divided by parallel time. Adding processors shrinks only the parallel portion, so the sequential portion limits how fast the solution can get.
6Distributed computing
Distributed computing uses the same timing arithmetic, with one extra piece: the machines are separate, so sending the work out and collecting the results back takes real time, and that time is sequential.
The four searches overlap, but the split and the combine do not: 2 + 30 + 3 = 35 seconds instead of 120, a speedup of about 3.43, not 4.
Speed is only half the reason to distribute. Some problems cannot be solved on one computer at all, because the data would not fit in its storage or the processing would take far too long. Weather forecasts, search engines, and scientific projects that analyze huge data sets spread both the data and the work across many machines. Distributed computing lets much larger problems be solved, and solved faster, than a single computer could manage.
7Benefits and challenges
| Benefit | The challenge that comes with it |
|---|---|
| Parallel solutions finish faster by running independent pieces at once | Speedup is limited by the sequential portion; it falls short of the number of processors whenever there is a sequential portion |
| Parallel solutions scale better than sequential ones as problems grow | Beyond some point, adding more parallel processing no longer meaningfully helps |
| Distributed computing solves problems too large for one computer's storage or time | Splitting, sending, and combining across a network adds sequential time, and more machines mean more of it |
| Distributed systems can keep going if one machine fails | More machines and more communication mean more places for something to go wrong |
8Worked examples
Setup, then three tasks
A job has a 6-second setup, then tasks of 12, 9, 4 seconds that can run at the same time. Find the sequential time, the parallel time with enough processors, and the speedup.
- 1Sequential: 6 + 12 + 9 + 4 = 31 s.
- 2Parallel: the setup is added; the tasks overlap, so take the longest: 6 + 12 = 18 s.
- 3Speedup: 31 ÷ 18 ≈ 1.72.
Two processors, four tasks
Independent tasks take A 15 s, B 25 s, C 40 s, and D 20 s. Split them between two processors to finish as soon as possible.
- 1Total work is 100 s, so no split can beat 50 s, and C alone is 40 s.
- 2If C runs alone, the other processor gets 60 s. If C shares, the best partner is the shortest task: C + A = 55 s.
- 3Then B + D = 45 s on the other processor. Checking every possible split confirms nothing finishes sooner.
Many processors
A program has 60 s of parallel work and 10 s of sequential work. What is the time with 3 processors? With as many processors as you like?
- 13 processors: 60 ÷ 3 + 10 = 30 s.
- 2With more and more processors the parallel part shrinks toward 0, but the 10 s remain.
“Four processors, four times faster”
A job is a 4-unit setup followed by 48 units of work that can be split evenly. A student claims 4 processors make it 4 times faster. Check the claim.
- 11 processor: 4 + 48 = 52 units.
- 24 processors: 4 + 48 ÷ 4 = 16 units.
- 3Speedup: 52 ÷ 16 = 3.25.
Too big for one computer
A research group needs to analyze 2 petabytes of telescope images, far more than any single computer they own can store. Which model fits, and why?
- 1Sequential on one computer fails on storage before speed even matters.
- 2Parallel computing inside one computer still has only that computer's storage.
- 3Distributed computing spreads the images and the work across many machines.
9Common mistakes
Tasks that run at the same time count once, as the longest of them. Adding them gives the sequential time.
Speedup is sequential ÷ parallel. An answer below 1 means you flipped it.
The sequential portion runs no matter how many processors there are, so the speedup is always less than the number of processors once there is any sequential work.
Splitting the work and combining the results across a network take time that does not overlap. Add it.
“The sequential solution takes 6 + 12 + 9 + 4 = 31 seconds. The parallel solution takes the 6-second setup plus the longest parallel task, 12 seconds, for 18 seconds. The speedup is 31 ÷ 18 ≈ 1.72; it is not 3 because the setup cannot run in parallel.”
Show both times, the speedup, and what limits it.