Overview

Message passing is a communication paradigm in computing where one component (thread, process, or node) sends a discrete packet of data — a message — to another. Messages typically carry a header and a payload and are used to coordinate actions, transfer values, or signal events. Unlike shared-memory approaches, message passing transfers information by explicit communication rather than by sharing mutable state.

Modes and characteristics

Message systems differ by timing and addressing semantics. Common distinctions include:

  • Synchronous (blocking send/receive) versus asynchronous (nonblocking send, buffered delivery).
  • Direct addressing (sender names recipient) versus indirect (mailboxes, topics, or queues).
  • Ordered versus unordered delivery, and reliable versus best-effort guarantees.

Mechanisms and common implementations

Message passing appears at many layers: operating system IPC primitives (pipes, sockets, native message queues), language-level concurrency models (actor systems, channels), middleware (message brokers, publish–subscribe systems), and high-performance libraries (e.g., MPI for parallel computing). Implementations can buffer messages, persist them to disk, or stream them in memory, depending on requirements.

Uses and examples

Typical uses include coordinating concurrent tasks, building microservices, implementing event-driven user interfaces, and composing distributed applications. Patterns built on message passing include request/response, publish/subscribe, work queues, and event sourcing. In actor-style programming each actor has a mailbox and reacts to messages one at a time, simplifying reasoning about concurrency.

Design considerations and trade-offs

Designing a message-based system requires attention to serialization format, latency and throughput, ordering and delivery semantics, idempotence, backpressure, routing, and security. Message passing favors decoupling and fault containment but can add copying overhead, increased complexity for consistency, and operational needs such as monitoring and retention.

Distinctions and notable facts

Compared with shared memory, message passing reduces direct contention and makes communication explicit, which can simplify reasoning about concurrency and distribution. It is a foundational idea in modern distributed architectures and concurrent language designs, and it scales from tiny embedded systems to global service meshes.