What it is
Parallelism is doing several pieces of work at the same instant on separate execution resources: CPU cores, threads, processes, machines. It differs from concurrency, which is about structuring a program so many tasks are in progress at once (they may interleave on one core). Parallelism needs hardware that can actually run things simultaneously.
In system design it shows up in two forms:
- Throughput parallelism: many independent requests or jobs processed side by side by a pool of workers.
- Latency parallelism: one request split into parts that run at the same time (scatter-gather, fan-out to shards or services), then merged.
Why it exists
Single-core speed has grown slowly since the mid-2000s; core counts and machine counts have not. A modern server has dozens of cores, and a cluster has thousands. Using them requires splitting work. For latency-sensitive work such as search over a large index, splitting the data across shards and querying them in parallel is often the only way to answer within a budget.
How it works
Worker pools. A pool of N workers takes independent jobs from a queue. If jobs share nothing, capacity is roughly N ÷ (time per job): four workers at 50 ms per job finish about 80 jobs per second.
The serial part. Almost every workload has a part that cannot run in parallel: updating a shared counter under a lock, appending to a single log, a single-writer database row, merging results, the coordinator that hands out work. Amdahl’s law (1967) quantifies the effect for a fixed amount of work with serial fraction s:
speedup(N) = 1 / (s + (1 − s) / N) limit as N → ∞: 1 / s
With s = 0.2, 4 cores give 2.5×, 16 cores 4×, and no number of cores more than 5×. With s = 0.05 the limit is 20×. For a stream of requests the same ceiling appears as a throughput cap: if every request needs 10 ms inside a section only one request can enter, the system completes at most 100 requests per second.
Worse than Amdahl. Coordination often grows with the number of workers: lock contention, cache-line bouncing between cores, more participants to synchronise. Gunther’s Universal Scalability Law adds a coherence term for this, which is why throughput curves can peak and then fall as you add workers.
Gustafson’s view. Amdahl assumes a fixed problem size. Gustafson’s law observes that with more processors people usually solve bigger problems in the same time, where the parallel part grows and the serial part does not. Both are true; they answer different questions (faster on the same work versus more work in the same time).
Fan-out and fan-in. A request split into N parallel calls finishes when the last call returns. If each call is slow with probability p, the request is slow with probability 1 − (1 − p)^N. With p = 1%: N = 4 → ~4%, N = 20 → ~18%, N = 100 → ~63%. This is the effect described in Dean and Barroso’s “The Tail at Scale” (2013).
When to use it
- Independent requests or jobs (stateless web tiers, batch processing, media encoding, message consumers).
- Data that partitions cleanly, so each worker or shard owns a disjoint part (sharded search, map-reduce style aggregation).
- Latency budgets that a sequential chain of calls cannot meet, where the calls do not depend on each other.
When not to
- When a shared resource is already the bottleneck: more workers only lengthen the line in front of it.
- When calls depend on each other’s results; forcing them parallel means speculative work you may throw away.
- When the parallel part is tiny compared with the overhead of splitting, dispatching and merging.
- Very wide fan-outs on a latency-critical path, unless you also manage the tail.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| More workers | Throughput, while work is independent | Memory, contention, more coordination; nothing past the serial ceiling |
| Finer-grained locks | A smaller serial part, higher ceiling | Complexity, deadlock risk, harder reasoning about invariants |
| Wider fan-out (more shards) | Less work per shard, more parallel capacity | Higher chance that some branch is slow; more requests in total |
| Hedged requests | Much shorter tail | A few percent extra load; only safe for idempotent requests |
| Partial results | Bounded latency | Lower quality or completeness on some responses |
Alternatives
- Make the serial part faster: less work inside the critical section, lock-free or sharded data structures (striped counters), batching updates.
- Avoid sharing: partition state so each worker owns its own part (per-core or per-partition designs, actor models).
- Precompute: move work off the request path into background jobs, so less needs to run in parallel at request time.
- Narrower fan-out: fewer, larger shards or a two-level aggregation tree, so each request waits on fewer branches.
Failure modes
- Serial ceiling: adding cores or instances with no throughput gain because a lock, a single writer or a single hot row is saturated.
- Contention collapse: throughput falls as workers are added because they spend their time fighting over the same lock or cache line.
- Tail amplification: every backend meets its P99 target, yet most user requests are slow because each touches many backends.
- Hedging storms: hedging without a delay, or retrying on top of hedging, multiplies load exactly when servers are already slow.
- Unbounded fan-out: one request spawns hundreds of calls and exhausts connection pools or thread pools downstream.
In production
Profile before scaling: look at lock wait time, single-threaded stages (one consumer per partition, one leader), and per-core CPU, not only the average. For fan-out paths, track latency per branch and for the whole request, set a deadline per call below the request’s budget, and decide what to do when a branch misses it (fail, retry once on a replica, or return partial results). Hedge only idempotent reads, typically after the branch’s P95, and cap the hedge rate. Search engines and large key-value stores commonly use these techniques.
Common misconceptions
- “Twice the cores, twice the speed.” Only for the parallel part. The serial part does not shrink, and coordination costs often grow.
- “Parallel calls cost the average latency.” They cost the maximum: the slowest branch decides.
- “If every backend meets its P99, users see P99 behaviour.” With fan-out, a backend’s P99 can become the user’s median.
- “Concurrency and parallelism are the same.” Concurrency is about managing many tasks in progress; parallelism is about running them at the same instant.
Interview angle
When a design adds instances to scale, interviewers ask what is shared: a database primary, a global lock, a sequence generator, a single partition. Name the serial part and quote Amdahl’s limit (“if 5% is serial we cap at 20×”). For scatter-gather designs (search, feeds, aggregation), say that latency is the slowest branch, estimate tail amplification with 1 − (1 − p)^N, and propose deadlines, partial results and hedged requests for idempotent reads.
Model assumptions
Simplified model, not a benchmark. Jobs arrive randomly (Poisson). Each job needs about 40 ms of parallelisable work (lognormal, cv 0.3) plus about 10 ms (later 4 ms) inside a critical section; the critical section is modelled as a separate one-worker stage, and a worker stays busy while it waits for it. Workers stand in for cores or threads; utilisation is the fraction of busy workers, not CPU. The four shards have 8 workers each and a heavy-tailed service time (lognormal, mean 10 ms, cv 1.0); network hops take 1 ms. The aggregator calls all four shards at the same time and answers when the last one has answered, so a query takes as long as its slowest call; the tail figures (call P50, call P99, share of queries slower than a call’s P99) are measured on those simulated queries. The slow shard is the same shard working 8× slower. The hedge router asks Shard 4 and its replica at the same moment and passes on the first answer, so it duplicates every call; a real hedge waits about the call’s P95 before sending the copy and cancels the loser, which the model does not do. The 1 − (1 − p)^N figures assume independent calls. Numbers are illustrative.