/ˌmʌltiˈprəʊsɛsɪŋ/

noun … “Multiple processes running in parallel.”

Multiprocessing is a computing technique in which multiple independent processes execute concurrently on one or more CPUs or cores. Each process has its own memory space, file descriptors, and system resources, unlike Threading where threads share the same memory. This isolation allows true parallel execution, enabling CPU-bound workloads to utilize multi-core systems efficiently and avoid limitations imposed by mechanisms like the GIL in Python.

Key characteristics of Multiprocessing include:

  • Process isolation: memory and resources are separate, reducing risks of data corruption from concurrent access.
  • True parallelism: multiple processes can run simultaneously on separate cores.
  • Inter-process communication (IPC): data can be exchanged using pipes, queues, shared memory, or sockets.
  • Overhead: processes are heavier than threads, requiring more memory and context-switching time.

In a typical workflow, a Python developer performing CPU-intensive image processing might create a pool of worker processes using the multiprocessing module. Each process operates on a subset of the dataset independently. Once all processes finish, results are collected and combined. Unlike Threading, this approach achieves near-linear speedup proportional to the number of cores, because each process executes bytecode independently of the GIL.

Example usage in Python:

from multiprocessing import Pool

def square(x):
    return x * x

with Pool(4) as p:
    results = p.map(square, [1, 2, 3, 4])
print(results)

Here, four separate processes compute the squares in parallel, and the results are aggregated once all computations complete.

Conceptually, Multiprocessing is like having multiple independent kitchens preparing dishes simultaneously. Each kitchen has its own ingredients, utensils, and chef, so tasks proceed in parallel without interference, unlike multiple chefs sharing a single workspace (as in Threading).

See Threading, Global Interpreter Lock, Python, Concurrency.