AP COMPUTER SCIENCE PRINCIPLES • COMPUTING SYSTEMS AND NETWORKS

Parallel and Distributed Computing

How dividing work across processors and machines enables solutions that no single computer could achieve alone.

Historical Context & Motivation

For decades, improvements in computing speed followed a simple playbook: make the processor's clock run faster. Chip manufacturers packed more transistors onto silicon, and each new generation of hardware could churn through instructions more quickly than the last. By the early 2000s, however, physical limits—particularly heat dissipation and power consumption—made it impractical to keep increasing clock speeds indefinitely. Engineers pivoted toward a different strategy: instead of making one processor do everything faster, they would use multiple processors working together. This shift gave rise to two complementary paradigms—parallel computing and distributed computing—that now underpin virtually every large-scale computation, from weather forecasting to social-media feeds.

1960s
Early Multiprocessor Systems
Universities and government labs built the first multiprocessor machines, such as the ILLIAC IV, to tackle scientific simulations that overwhelmed any single CPU.
1980s
Massively Parallel Architectures
The Connection Machine (CM-1) used up to 65,536 simple processors in parallel, demonstrating that many small processors could outperform a single large one for certain tasks.
1995
Beowulf Clusters
NASA engineers linked commodity PCs over a local network to create a cost-effective supercomputer, pioneering the distributed-cluster model.
2004
Multi-Core Processors Go Mainstream
Intel and AMD shipped the first widely available dual-core desktop CPUs, making parallelism relevant to everyday software developers.
2010s–Present
Cloud and Edge Computing
Services like AWS, Google Cloud, and Azure distribute computation across thousands of networked servers worldwide, enabling on-demand scalability for billions of users.

The central question this lesson addresses is: How can computational tasks be divided among multiple processors or machines, and what are the benefits, challenges, and limits of doing so? Understanding these ideas is essential not only for the AP exam but also for grasping how modern technology delivers the speed and reliability we take for granted.

Core Principles & Definitions

Before diving into the mechanics, it is important to distinguish the two paradigms and the vocabulary that surrounds them. A sequential computing model executes one instruction at a time in a strict order. By contrast, parallel computing splits a task into subtasks that run simultaneously on multiple processors within a single machine, while distributed computing spreads subtasks across separate machines connected by a network. In practice, modern systems blend both: a cloud data center (distributed) contains servers that each have multi-core CPUs (parallel).

1

Sequential Execution

Instructions run one after another on a single processor. The total time equals the sum of all individual task times. Simple to reason about, but limited in speed.
2

Parallel Execution

Multiple processors in one machine handle different subtasks at the same time. Shared memory allows fast data exchange, but coordination overhead can arise.
3

Distributed Execution

Subtasks are delegated to physically separate computers over a network. Adds fault tolerance and scalability, but introduces network latency and communication cost.
4

Speedup

The ratio of sequential execution time to parallel execution time. Ideal (linear) speedup equals the number of processors, but real speedup is nearly always less due to overhead.
5

Scalability

A system's ability to handle larger workloads by adding more processors or machines. A scalable solution maintains efficiency as it grows.
KEY TAKEAWAY
Think of parallel computing like a team of chefs in one kitchen—they share the same counter space and ingredient shelf, so they can pass items quickly but must be careful not to bump into each other. Distributed computing is more like several restaurants in different cities collaborating on a menu: each kitchen operates independently with its own supplies, and coordination happens over the phone. The first approach is fast but constrained in size; the second scales massively but requires more communication effort.

Visual Explanation — Sequential vs. Parallel Execution

In the sequential model (top), each task must wait for the previous one to finish, so total time is the sum of all task durations. In the parallel model (bottom), four processors each handle one task concurrently, so total time equals only the longest individual task. The red dashed line marks the moment all four processors have finished.

The diagram above illustrates the fundamental advantage of parallelism when subtasks are independent—that is, when no subtask depends on the output of another. In the ideal case, splitting work evenly among n processors yields a speedup factor close to n. In reality, however, some portion of the work is inherently sequential—for example, initializing shared data structures or merging partial results—and this limits the achievable speedup, a constraint formalized by Amdahl's Law.

Mathematical Framework — Speedup & Amdahl's Law

While the AP Computer Science Principles exam does not require complex derivations, understanding the quantitative relationships behind parallel speedup helps you reason about why adding more processors does not always help. Two key formulas capture this insight.

SPEEDUP
Speedup = T_sequential / T_parallel
Where Tsequential is the time on one processor and Tparallel is the time using multiple processors. A speedup of 4× means the parallel version runs four times faster.
AMDAHL'S LAW
Speedup ≤ 1 / ( S + (1 − S) / N )
Where S is the fraction of the program that must run sequentially (0 ≤ S ≤ 1), and N is the number of parallel processors. As N → ∞, maximum speedup approaches 1/S. This means even a small sequential fraction imposes a hard ceiling on speedup.

Consider a program where 25% of the work is inherently sequential (S = 0.25). Even with an infinite number of processors, the maximum speedup is 1 / 0.25 = 4×. No matter how much hardware you throw at the problem, three-quarters of the original time can be parallelized, but that stubborn quarter remains a bottleneck. This insight is central to the AP exam's emphasis on understanding the limitations of parallel solutions.

📋 AP EXAM TIP
The College Board frequently tests whether students understand that not all problems benefit equally from parallelism. If a problem has significant sequential dependencies—where one step's output feeds the next—adding processors may yield diminishing returns. Be ready to explain why a parallel solution doesn't always achieve linear speedup.

Models of Parallel & Distributed Computing

Different computational problems call for different parallelization strategies. The way tasks are divided, the degree to which they communicate, and the hardware topology all influence which model is appropriate. Below is a classification of the most common models you will encounter in AP CSP and in real-world computing.

Top row, left to right: shared-memory parallelism (processors access common RAM), message-passing distribution (nodes communicate over a network), and the MapReduce framework. Bottom row: task parallelism versus data parallelism, and fault tolerance via redundancy.
Comparison of parallel and distributed computing models
ModelCommunicationTypical Use CaseKey Advantage
Shared MemoryProcessors read/write common RAMMulti-threaded applications on a single multi-core machineVery low latency between processors
Message PassingNodes send explicit messages over a networkCluster computing, scientific simulationsScales to thousands of machines
Data ParallelismSame operation applied to chunks of data simultaneouslyImage processing, training neural networks on GPUsExploits regular structure of data
Task ParallelismDifferent functions run concurrently on different dataWeb servers handling multiple user requestsHandles heterogeneous workloads

Worked Example — Applying Amdahl's Law

Suppose a program takes 100 seconds to run on a single processor. Analysis reveals that 40% of the program's execution must remain sequential, while the remaining 60% can be perfectly parallelized. The team plans to use 8 processors. What is the expected speedup, and how long will the program take?

Computing Speedup with Amdahl's Law
1
Step 1 — Identify Given ValuesSequential fraction S = 0.40. Number of processors N = 8. Original sequential time Tseq = 100 seconds.
2
Step 2 — Apply Amdahl's LawSpeedup = 1 / (S + (1 − S) / N) = 1 / (0.40 + 0.60 / 8) = 1 / (0.40 + 0.075) = 1 / 0.475.
3
Step 3 — Calculate SpeedupSpeedup = 1 / 0.475 ≈ 2.105. This means the program runs about 2.1 times faster with 8 processors—far below the ideal 8× speedup.
Speedup ≈ 2.1×
4
Step 4 — Compute Parallel Execution TimeTparallel = Tseq / Speedup = 100 / 2.105 ≈ 47.5 seconds. The sequential portion alone accounts for 40 seconds, and the parallelized portion (60 seconds originally) takes 60 / 8 = 7.5 seconds.
T_parallel ≈ 47.5 seconds
5
Step 5 — Interpret the ResultDespite using 8 processors, the speedup is only about 2.1× because 40% of the program cannot be parallelized. Amdahl's Law tells us that even with infinitely many processors, the maximum speedup for this program would be 1 / 0.40 = 2.5×. This shows why reducing the sequential fraction is often more valuable than simply adding more hardware.

Benefits, Challenges & Tradeoffs

Parallel and distributed computing are not free lunches. Every design decision involves tradeoffs, and the AP exam frequently asks students to evaluate whether parallelizing a given solution is worthwhile. The table below summarizes the major benefits alongside their corresponding challenges.

Key tradeoffs in parallel and distributed computing
BenefitChallengeExample
Faster executionCoordination overhead—processors may idle while waiting for data from othersMerging sorted sub-arrays requires a synchronization step
ScalabilityDiminishing returns as sequential fraction dominates (Amdahl's Law)Adding 100 more servers to a 90% sequential program barely helps
Fault toleranceComplexity of maintaining data consistency when nodes failA bank's distributed database must keep balances accurate even if a server crashes
Handling massive dataNetwork latency and bandwidth limit how fast data can move between machinesProcessing petabytes of web logs across data centers
Resource sharingSecurity risks increase with more network connections; race conditions can produce incorrect resultsTwo threads writing to the same variable simultaneously may corrupt data
KEY TAKEAWAY
Think of parallelism like building a house with multiple construction crews. If one crew is laying the foundation (which must come first), adding extra roofers won't make the project finish sooner—they'll just stand around waiting. Similarly, the sequential bottleneck in a program limits how much parallelism can help. The art of parallel design is identifying which parts of a computation are truly independent and minimizing the sequential fraction.

Connection to Advanced Topics & the Real World

The principles of parallel and distributed computing you study in AP CSP are the same ones that power the most demanding applications in technology today. Understanding these connections helps you see why the AP content matters beyond the exam. The table below maps AP-level concepts to their advanced counterparts.

From AP CSP concepts to advanced computing topics
AP CSP ConceptAdvanced / Real-World Extension
Parallel execution on multi-core CPUsGPU computing with thousands of cores (CUDA, OpenCL); training large language models like GPT on GPU clusters
Distributed systems across a networkBlockchain networks, content delivery networks (CDNs), and the global DNS system
Speedup and Amdahl's LawGustafson's Law (scaling the problem size with processors); performance modeling in high-performance computing (HPC)
Fault tolerance via redundancyConsensus algorithms (Paxos, Raft); the CAP theorem governing trade-offs between consistency, availability, and partition tolerance
Sequential vs. parallel solution designConcurrent programming paradigms (threads, async/await, actor model); race conditions, deadlocks, and formal verification

As you move into college-level computer science courses, you will encounter formal models of concurrency, learn to write multi-threaded code, and grapple with the subtle bugs that arise when multiple processes share resources. The intuition you build now—understanding why parallelism helps, when it fails, and what limits it—provides the conceptual scaffolding for all of that deeper work.

Practice Problems

1
A programmer wants to speed up a program that processes a list of 1,000 images. Each image can be processed independently of the others. Which of the following best explains why running this program on a computer with 4 processors is likely to be faster than running it on a computer with 1 processor?
2
A program takes 200 seconds to run sequentially. 80% of the program can be parallelized, and 20% must remain sequential. Using Amdahl's Law with 4 processors, what is the approximate parallel execution time?
3
A school wants to build a distributed system where multiple computers collaborate to host a website. Which TWO of the following are advantages of using a distributed system rather than a single powerful server?
PROBLEM 4APPLIED
A social media company processes 10 million photos daily to detect inappropriate content. Currently, one server processes each photo sequentially in 0.01 seconds per photo. (a) How long does it take the single server to process all 10 million photos? (b) The company decides to distribute the task across 100 servers, with each server processing an equal share. Assuming no overhead, how long would the distributed solution take? (c) In practice, the distributed solution requires 500 seconds of setup and coordination overhead. Explain whether the distributed approach is still worthwhile and justify your reasoning.
PROBLEM 5CRITICAL THINKING
Consider two programs: Program X: Analyzes weather data. 90% of the computation consists of independent calculations on separate geographic regions. 10% involves combining regional results into a global forecast. Program Y: Simulates fluid dynamics. Each time step's computation depends on the results of the previous time step. Only 20% of each time step can run in parallel across data points; the remaining 80% is sequential dependency resolution. (a) Using Amdahl's Law, calculate the maximum possible speedup for each program as the number of processors approaches infinity. (b) If a research lab has a budget to purchase either 8 processors or 64 processors, recommend which program would benefit more from the 64-processor purchase versus the 8-processor purchase. Justify your answer with calculations. (c) Propose one strategy the lab could use to improve the performance of Program Y beyond what additional processors alone can provide. (d) Explain how a distributed computing approach might introduce additional challenges for Program Y that would not affect Program X.

Summary — Parallel and Distributed Computing

Parallel computing splits tasks across multiple processors within a single machine, while distributed computing spreads work across separate networked machines. Both aim to reduce execution time by performing operations concurrently rather than sequentially. The potential speedup is quantified by the ratio of sequential time to parallel time, and Amdahl's Law reveals that the sequential fraction of a program imposes a hard ceiling on how much speedup additional processors can deliver.

Key models include shared-memory parallelism, message-passing distribution, data parallelism, and task parallelism. Benefits include faster execution, scalability, and fault tolerance, but challenges such as coordination overhead, network latency, and the inherent sequential bottleneck mean that parallelism is not a universal solution. For the AP exam, focus on understanding when and why parallel and distributed approaches improve performance, and being able to explain their limitations.

Varsity Tutors • AP Computer Science Principles • Parallel and Distributed Computing