Find a course

Module 3: Computer Systems and NetworksLesson 8 of 1111 min

Parallel and Distributed Computing

Compare sequential, parallel and distributed computing, calculate the running time and speedup of a parallel solution, and see why processors have limits.

Step 1 of 9Learn

Many hands make light work

Imagine your class has to grade 300 quizzes. One teacher grading alone, quiz after quiz, is sequential computing: tasks done one at a time, in order. If three teachers split the stack, each grades 100 at the same time. That's parallel computing: the work is broken into smaller parts that run simultaneously on multiple processors.

Modern devices do this constantly. A typical phone or laptop processor has several cores, each able to run instructions independently, and graphics chips have thousands of small cores that work on different pixels at once.

Distributed computing goes further: multiple separate computers, often in different places, work together on a problem over a network. Search engines index the web this way, climate scientists run huge simulations this way, and volunteer projects have let people donate their home computers' spare time to research. Distributed computing makes it possible to solve problems that would be too large or too slow for any single machine, both because of processing time and because of storage needs.

The trade-off: splitting work and combining the results takes effort. Computers must communicate, and some tasks simply can't start until others finish.

Step 2 of 9Practice · Sort into groups

Sequential, parallel or distributed?

Tap an item, then tap its group (or drag it there).

Step 3 of 9Learn

Calculating parallel time and speedup

AP questions often give a set of tasks with their times and ask how long they take sequentially and in parallel.

Sequential time is simply the sum of all task times, since tasks run one after another.

Parallel time is how long it takes when tasks are split among processors. Each processor runs its own tasks one after another, and the whole job finishes when the slowest processor finishes. So parallel time is the largest total among the processors.

Example: four tasks take 40, 30, 20 and 10 seconds, and there are two processors.

  • Sequential time: 40 + 30 + 20 + 10 = 100 seconds.
  • A good split: processor 1 runs 40 + 10 = 50; processor 2 runs 30 + 20 = 50. Parallel time = 50 seconds.
  • A poor split: processor 1 runs 40 + 30 = 70; processor 2 runs 20 + 10 = 30. Parallel time = 70 seconds, because the job waits for processor 1.

Speedup measures the improvement:

speedup = sequential time ÷ parallel time

With the good split, speedup = 100 ÷ 50 = 2. With the poor split, it's only 100 ÷ 70 ≈ 1.43.

Notice that the order of assignment matters, and that no split can ever finish faster than the single longest task. With tasks of 40, 30, 20 and 10, even a hundred processors can't beat 40 seconds.

Tasks of 40, 30, 20 and 10 seconds: 100 seconds sequentially, 50 seconds on two processorsSequential40302010Processor 14010Processor 23020parallel: 50 ssequential: 100 sspeedup = 100 ÷ 50 = 2

Step 4 of 9Try the calculator

Speedup calculator

Enter the sequential running time and the parallel running time (the time of the busiest processor) to compute the speedup.

Speedup
2
Time saved
50 s

Step 5 of 9Practice · Work it out

Three tasks take 50, 30 and 20 seconds. They run on two processors in parallel, with the 50-second task on one processor and the other two tasks on the second. What is the speedup?

Step 6 of 9Learn

The limits of adding processors

If two processors halve the time, will a thousand processors make a job a thousand times faster? Almost never.

Most programs have a sequential portion that can't be split. Before grading can start, someone has to collect the quizzes; after grading, someone must add up the scores. Those steps take the same time no matter how many helpers there are. As you add processors, the parallel portion shrinks toward zero, but the sequential portion stays, so the speedup levels off.

Example: a job has 20 seconds of work that must run sequentially and 80 seconds that can be split evenly. On one processor: 100 seconds. On 2 processors: 20 + 40 = 60 seconds. On 4: 20 + 20 = 40. On 80: 20 + 1 = 21. Even with infinitely many processors, it can never go below 20 seconds, so the speedup can never exceed 100 ÷ 20 = 5.

There are other costs too. Processors need to communicate, which takes time, and in distributed systems that communication travels over a network. Sometimes adding more machines slows things down because they spend more time coordinating than computing.

So the efficiency of a parallel solution is still limited by its sequential portion, and good engineers look for the parts of a problem that are truly independent.

Step 7 of 9Explore

Why more processors stop helping

A job has a part that must run sequentially and a part that can be split evenly. The curve shows total time as the number of processors (x) grows.

050100150200 5101520
Time on 1 processor
100 s
Time on 4 processors
40 s
Speedup on 4 processors
2.5
Speedup on 1,000 processors
4.98

Step 8 of 9Note

Step 9 of 9Practice · Choose one

A job has 30 seconds that must run sequentially and 60 seconds that can be divided evenly among processors. What is the shortest possible running time with 3 processors?