Message passing is a communication mechanism where independent processes interact by sending and receiving messages over a network.
- Each process runs in its own address space.
- No shared memory is used between distributed nodes.
- Messages contain data along with control information.
Core Components
1. Processes (Sender and Receiver)
- A sender is the process that initiates communication by transmitting a message.
- A receiver is the process that accepts and processes the incoming message.
- Both processes execute independently on separate machines or nodes.
2. Communication Channels
- A communication channel is the medium through which messages travel.
- It connects two or more distributed processes.
- They handle message transmission across the network.
3. Send() and Receive() Operations
- Send() is used by a process to transmit a message.
- Receive() is used to accept an incoming message.
- These operations define how communication is initiated and completed.
4. Message Structure (Header + Data)
- A message consists of control information and actual content.
- The header contains metadata such as sender ID, receiver ID, and message type.
- The data (payload) contains the actual information being transmitted.
Communication Models
1. Synchronous Communication
The sender and receiver coordinate directly during message exchange, and one or both processes wait until the communication completes.
- The sender blocks until the receiver accepts the message.
- The receiver may also block until a message arrives.
- Commonly follows a request–response interaction pattern.
2. Asynchronous Communication
Allows processes to exchange messages without waiting for each other during transmission.
- The sender continues execution after sending the message.
- The receiver processes the message whenever it becomes available.
- Improves concurrency and system responsiveness.
Communication Patterns
1. Unicast (One-to-One)
It is a communication pattern where a message is sent from one sender to exactly one receiver.

- Direct communication between two specific processes.
- Used in client–server interactions.
- Ensures the message is delivered to a single intended node.
- Common in request–response communication.
2. Multicast (One-to-Many Selected Nodes)
Allows a sender to transmit a message to a selected group of receivers.

- The message is delivered to multiple specific nodes.
- Reduces the need to send separate messages individually.
- Useful in distributed group communication.
- Efficient for coordinated operations among selected services.
3. Broadcast (One-to-All)
It is a pattern where a message is sent from one sender to all nodes in the network.

- Every node in the system receives the message.
- Used for announcements or system-wide updates.
- Simplifies information dissemination.
- May increase network traffic in large systems.
Message Passing Semantics
1. Reliability
It defines how the system guarantees message delivery between sender and receiver.
- At-most-once: A message is delivered either once or not at all; duplicates are prevented.
- At-least-once: A message is guaranteed to arrive, but duplicates may occur.
- Exactly-once: A message is delivered once and only once; no loss and no duplication.
- Reliability mechanisms often use retries and acknowledgments.
2. Message Ordering
Ensures that messages are received in a defined sequence.
- FIFO Ordering: Messages from one sender arrive in the same order they were sent.
- Causal Ordering: Messages that are causally related are delivered in order.
- Total Ordering: All processes receive messages in the same global order.
- Ordering is important for maintaining consistency in distributed systems.
3. Buffering and Acknowledgments
Help manage message flow and delivery confirmation.
- Messages may be temporarily stored in buffers before processing.
- Buffers prevent data loss when the receiver is busy.
- Acknowledgment (ACK) confirms successful message delivery.
- Timeouts may trigger retransmission if acknowledgment is not received.
Implementation Mechanisms (High-Level Only)
1. TCP and UDP
These are transport layer protocols used to transmit messages across networks.
- TCP (Transmission Control Protocol) provides reliable and ordered message delivery.
- Ensures error checking and retransmission of lost messages.
- UDP (User Datagram Protocol) provides faster but unreliable communication.
- Suitable choice depends on whether reliability or speed is the priority.
2. Message Queues
Enable asynchronous communication between distributed components.
- Messages are stored in a queue until the receiver processes them.
- Decouples sender and receiver in time and execution.
- Supports load balancing and fault tolerance.
- Common in event-driven and microservices architectures.
3. RPC and gRPC
Allow invoking remote services like local functions.
- Abstract low-level message handling.
- Automatically manage request and response messaging.
- gRPC supports efficient communication using structured data formats.
- Widely used in modern distributed and cloud-based systems.
Advantages
- Scalability: New nodes can be added easily without modifying existing components.
- Loose Coupling: Processes remain independent and interact only through messages.
- Fault Isolation: Failure in one process does not directly affect others.
- Flexibility: Components can run on different machines or locations.
- Security: Controlled message exchange reduces direct memory access risks.
Disadvantages
- Network Latency: Communication delays may impact performance.
- Message Loss: Unreliable networks can cause dropped messages.
- Synchronization Issues: Coordinating distributed processes is complex.
- Overhead: Message formatting and transmission add extra processing cost.
- Failure Handling Complexity: Requires retry and recovery mechanisms.
Applications
- Microservices Architecture: Services communicate using lightweight message exchange.
- Distributed Databases: Nodes exchange updates and queries.
- Cloud Computing: Services coordinate across multiple data centers.
- Parallel Computing: Processors share intermediate results.
- Real-Time Systems: Used in event-driven and streaming applications.