Articles

Concurrency vs Parallelism: The Difference Explained

Concurrency is structuring a program to handle many tasks in overlapping time; parallelism is running tasks at the same instant. How they differ and relate.

The Lycoris Team The Lycoris Team · · 5 min read
A black stopwatch

Concurrency is about dealing with many things at once: structuring a program so multiple tasks can make progress during overlapping periods of time. Parallelism is about doing many things at once: literally executing multiple computations at the same instant on separate hardware. A single-core machine can be concurrent but never parallel. A multi-core machine can be both. The two ideas are related, often confused, and solve different problems.

A kitchen analogy

Picture one cook preparing three dishes. They put water on to boil, chop vegetables while it heats, then stir a sauce while the pasta cooks. Only one pair of hands is working at any moment, but all three dishes progress. That is concurrency: interleaving tasks so waiting on one doesn’t block the others.

Now picture three cooks, each making one dish simultaneously. That is parallelism: more workers executing at the same time.

A busy restaurant uses both. Several cooks work in parallel, and each one juggles several dishes concurrently.

Concurrency vs parallelism at a glance

ConcurrencyParallelism
Core ideaManaging multiple tasks in overlapping timeExecuting multiple tasks at the same instant
Hardware neededWorks on a single coreRequires multiple cores, processors, or machines
Main goalResponsiveness and handling many waiting tasksRaw throughput on heavy computation
Best forI/O-bound work: network calls, disk, user inputCPU-bound work: number crunching, encoding, rendering
Typical toolsEvent loops, async/await, coroutines, threadsMultiple threads or processes, SIMD, GPUs, clusters
Main hazardOrdering bugs, race conditionsCoordination overhead, contention, uneven work splits

Why concurrency matters even on one core

Most programs spend a surprising amount of time waiting — for a database, a network response, a file read, or a keypress. If a program handles one request at a time and blocks during every wait, the CPU sits idle. Concurrency lets it start another task during that wait.

JavaScript is the canonical example. A browser tab or a Node.js process runs your code on a single thread, yet it can have hundreds of network requests in flight. The event loop picks up whichever callback is ready, runs it to completion, and moves on. async/await is syntax for writing that interleaving as if it were sequential code. Nothing runs in parallel on the main thread, but the program is highly concurrent.

Under the hood, operating systems provide efficient readiness notification so a single thread can watch many connections at once; epoll vs io_uring covers how Linux does it.

Why parallelism matters for heavy computation

Concurrency doesn’t help when the bottleneck is the CPU itself. If you need to resize ten thousand images, interleaving them on one core finishes no sooner than doing them one by one. You need more cores working at once.

Parallelism shows up at several scales:

  • Instruction level: a single core executes multiple independent instructions per cycle.
  • Data level: SIMD instructions apply one operation to a vector of values; GPUs take this idea to thousands of lanes.
  • Thread level: separate threads or processes run on separate cores. In the browser this means a web worker; in Node.js, worker threads.
  • Machine level: a job is split across a cluster of computers.

How they relate

Parallelism is one way to execute a concurrent design. If you’ve already broken a problem into independent tasks — the concurrent structure — a runtime can spread those tasks across cores to run them in parallel. Without that structure, there’s nothing to parallelize. That’s why concurrency is often described as a property of the program’s design and parallelism as a property of its execution.

The reverse is not true: a concurrent program does not automatically become faster with more cores. If its tasks are mostly waiting on I/O, adding cores changes little. If they contend for the same lock, adding cores can even make things slower.

The limits of parallel speedup

Doubling the cores rarely halves the runtime. Every program has some portion that must run sequentially — setup, combining results, a shared resource — and that portion caps the total speedup no matter how many cores you add. This is Amdahl’s law: if a tenth of the work is inherently serial, the program can never run more than ten times faster, even on unlimited hardware.

Coordination costs also eat into gains. Threads must synchronize access to shared data, and the hardware must keep caches consistent across cores. Problems like false sharing — where independent variables happen to sit on the same cache line — can quietly erase a parallel speedup.

The shared hazard: shared state

Both models get into trouble when multiple tasks touch the same mutable data. In a concurrent program, an await in the middle of a read-modify-write sequence can let another task slip in between. In a parallel program, two cores can genuinely modify the same memory at the same time. Either way, the result is a race condition. The defenses are the same family of tools: locks, atomic operations, message passing, and designs that keep data owned by a single task.

Choosing an approach

  • Lots of waiting (web servers, API clients, UIs): favor concurrency with an event loop or async I/O. It scales to many tasks with little memory.
  • Lots of computing (video, compression, simulations, model training): favor parallelism across cores, vector units, or GPUs.
  • Both: use a concurrent front end that hands CPU-heavy jobs to a pool of parallel workers. Many production systems look exactly like this.

The takeaway

Concurrency is a way of structuring work so many tasks can progress without blocking each other; parallelism is running work simultaneously on multiple execution units. Concurrency improves responsiveness for I/O-bound programs, even on one core. Parallelism improves throughput for CPU-bound programs, within the limits of serial work and coordination overhead. Good systems design concurrently and then execute in parallel where the work justifies it.

The Lycoris Team The Lycoris Team · · 5 min read

Process vs Thread: What's the Difference?

A process is a running program with its own memory; a thread is an execution path inside it that shares that memory. How they differ and when to use each.

#Computer Science #Performance #Backend
The Lycoris Team The Lycoris Team · · 5 min read

mmap Explained: How Memory-Mapped Files Work

mmap maps a file into a process's address space so it can be read like memory. How memory-mapped files work, when they beat read(), and their pitfalls.

#Computer Science #Performance #Backend
Takina Takina · · 5 min read

JavaScript Barrel Files: What They Are and Their Costs

A barrel file re-exports a folder's modules from one index file. Why barrels are convenient, how they slow builds, tests, and bundles, and the alternatives.

#JavaScript #TypeScript #Performance