Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
Resource Sharing in Distributed System
Next article icon

Message Passing in Distributed System

Last Updated : 12 Nov, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Message passing in distributed systems refers to the communication medium used by nodes (computers or processes) to communicate information and coordinate their actions. It involves transferring and entering messages between nodes to achieve various goals such as coordination, synchronization, and data sharing.

Message-Passing-in-Distributed-System
Message Passing in Distributed System

Table of Content

  • What is Message Passing in Distributed Systems?
  • Communication Protocols for Message Passing in Distributed Systems
  • Challenges for Message Passing In Distributed Systems
  • Message Passing in Distributed Systems Examples
  • Message Passing System vs. Shared Memory System in Distributed Systems

What is Message Passing in Distributed Systems?

The method by which entities or processes in a distributed system communicate and exchange data is known as message passing. It enables several components, which could be operating on different computers or nodes connected by a network, to plan their actions, exchange data, and work together to accomplish shared objectives.

  • Models like synchronous and asynchronous message passing offer different synchronization and communication semantics to suit system requirements.
  • Synchronous message passing ensures sender and receiver synchronization, while asynchronous message passing allows concurrent execution and non-blocking communication.

Importance of Message Passing

In distributed systems, where multiple independent components work together to perform tasks, message passing is crucial for inter-process communication (IPC). It enables applications to distribute workloads, share resources, synchronize actions, and handle concurrent activities across different nodes efficiently.

Types of Message Passing in Distributed Systems

Message passing describes the method by which nodes or processes interact and share information in distributed systems. Message passing can be divided into two main categories according to the sender and reciever's timing and synchronization:

1. Synchronous Message Passing

Synchronous message passing involves a tightly coordinated interaction between the sender and receiver. The key characteristics include:

  • Timing Coordination: Before proceeding with execution, the sender waits for the recipient to confirm receipt of the message or finish processing it.
  • Request-Response Pattern: often use a request-response paradigm in which the sender sends a message requesting something and then waits for the recipient to react.
  • Advantages:
    • Ensures precise synchronization between communicating entities.
    • Simplifies error handling as the sender knows when the message has been successfully received or processed.
  • Disadvantages:
    • May introduce latency if the receiver is busy or unavailable.
    • Synchronous blocking can reduce overall system throughput if many processes are waiting for responses.

2. Asynchronous Message Passing

Asynchronous message passing allows processes to operate independently of each other in terms of timing. Key features include:

  • Decoupled Timing: The sender does not wait for an immediate response from the receiver after sending a message. It continues its execution without blocking.
  • Event-Driven Model: Communication is often event-driven, where processes respond to messages or events as they occur asynchronously.
  • Advantages:
    • Enhances system responsiveness and throughput by allowing processes to execute concurrently.
    • Allows for interactions that are loosely connected, allowing processes to process messages at their own speed.
  • Disadvantages:
    • Requires additional mechanisms (like callbacks or event handlers) to manage responses or coordinate actions.
    • Handling out-of-order messages or ensuring message delivery reliability can be more complex compared to synchronous communication.

3. Unicast Messaging

Unicast messaging is a one-to-one communication where a message is sent from a single sender to a specific receiver. The key characteristics include:

  • Direct Communication: The message is targeted at a single, specific node or endpoint.
  • Efficiency for Point-to-Point: Since only one recipient receives the message, resources are efficiently used for direct, point-to-point communication.
  • Advantages:
    • Optimized for targeted communication, as the message is only sent to the intended recipient.
    • Minimizes network load compared to group messaging, as it doesn’t broadcast to unnecessary nodes.
  • Disadvantages:
    • Not scalable for group communications; sending multiple unicast messages can strain the system in larger networks.
    • Can increase the complexity of managing multiple unicast connections in large-scale applications.

4. Multicast Messaging

Multicast messaging enables one-to-many communication, where a message is sent from one sender to a specific group of receivers. The key characteristics include:

  • Group-Based Communication: Messages are delivered to a subset of nodes that have joined the multicast group.
  • Efficient for Groups: Saves bandwidth by sending the message once to all nodes in the group instead of individually.
  • Advantages:
    • Reduces network traffic by sending a single message to multiple recipients, making it ideal for content distribution or group updates.
    • Scales efficiently for applications where data needs to reach specific groups, like video conferencing or online gaming.
  • Disadvantages:
    • Complex to implement as nodes need mechanisms to manage group memberships and handle node join/leave requests.
    • Not all network infrastructures support multicast natively, which can limit its applicability.

5. Broadcast Messaging

Broadcast messaging involves sending a message from one sender to all nodes within the network. The key characteristics include:

  • Wide Coverage: The message is sent to every node, ensuring that all nodes in the network receive it.
  • Network-Wide Reach: Suitable for announcements, alerts, or updates intended for all nodes without targeting specific ones.
  • Advantages:
    • Guarantees that every node in the network receives the message, which is useful for critical notifications or status updates.
    • Simplifies dissemination of information when all nodes need to be aware of an event or data change.
  • Disadvantages:
    • Consumes significant network resources since every node, regardless of relevance, receives the message.
    • Can lead to unnecessary processing at nodes that don’t need the message, potentially causing inefficiency.

Communication Protocols for Message Passing in Distributed Systems

Communication protocols for message passing are crucial in distributed systems to guarantee the safe, effective, and dependable transfer of data between nodes or processes over a network. These protocols specify the formats, guidelines, and practices that control the construction, transmission, reception, and interpretation of messages. Typical protocols for communication in distributed systems include:

  • Transmission Control Protocol (TCP):
    • Data packets are reliably and systematically delivered between network nodes via TCP, which is a connection-oriented protocol.
    • It ensures that data sent from one endpoint (sender) reaches the intended endpoint (receiver) without errors and in the correct order.
    • Suitable for applications where data integrity and reliability are paramount, such as file transfers, web browsing, and database communication.
  • User Datagram Protocol (UDP):
    • UDP is a connectionless protocol that provides fast, lightweight communication by transmitting data packets without establishing a connection or ensuring reliability.
    • Used in real-time applications where low latency and speed are critical, such as streaming media, online gaming, and VoIP (Voice over IP).
  • Message Queuing Telemetry Transport (MQTT):
    • MQTT is a lightweight publish-subscribe messaging protocol designed for IoT (Internet of Things) and M2M (Machine-to-Machine) communication.
    • It enables effective data transfer between devices with limited computing power and bandwidth.
    • Ideal for IoT applications, smart home automation, remote monitoring, and telemetry data collection.
  • Hypertext Transfer Protocol (HTTP):
    • HTTP is a protocol used for transmitting hypermedia documents, such as HTML pages and multimedia content, over the World Wide Web.
    • While not typically considered a message passing protocol in the traditional sense, it's essential for web-based communication and distributed applications.

Challenges for Message Passing In Distributed Systems

Below are some challenges for message passing in distributed systems:

  • Scalability: Balancing the system's expanding size and message volume while preserving responsiveness, performance, and effective resource use.
  • Fault Tolerance: Ensuring system resilience against node failures, network partitions, and message loss through redundancy, replication, error handling mechanisms, and recovery strategies.
  • Security: protecting messages' confidentiality, integrity, and authenticity while guarding against illegal access, interception, and manipulation.
  • Message Ordering: Ensuring that messages arrive in the same order they were sent, especially in systems where order affects the outcome.

Message Passing in Distributed Systems Examples

Example 1:

Scenario:

Let's take example of an e-commerce platform where users place orders. When an order is placed, the order system sends a message to the payment processing service to handle payment, and then continues to process other orders without waiting for an immediate response.

Here, the order system doesn’t wait for confirmation that the payment was completed, allowing it to keep processing orders efficiently. This asynchronous message passing helps the platform handle a large volume of orders smoothly.

Example 2:

Scenario:

Let's take example of a stock trading app, when a user wants to buy or sell shares, the app sends a request to the trading server. The server checks if there are enough shares, processes the transaction, and confirms to the user before the app allows further actions.

This synchronous message passing means the app waits for the server’s response to ensure the transaction is complete. This is important for accuracy in trading, where users need immediate confirmation of each transaction.

Message Passing System vs. Shared Memory System in Distributed Systems

In distributed systems, communication between processes or nodes can be achieved through either message passing or shared memory systems. Below are some important differences between these two approaches:

Aspect

Message Passing System

Shared Memory System

Communication Model

Asynchronous or synchronous communication between processes.

Processes access and modify shared memory locations.

Data Exchange

Messages are copied from sender to receiver.

Processes share data directly through shared memory.

Decoupling

Processes are loosely coupled and do not access each other's memory directly.

Processes interact by reading and writing to shared memory.

Scalability

Scales well as communication is based on network protocols.

More challenging to scale across distributed nodes.

Performance

Introduces serialization/deserialization and network overhead.

Generally faster due to direct memory access.

Isolation

Processes are isolated, enhancing fault tolerance and security.

Requires synchronization mechanisms for data consistency.

Complexity

Management of message queues, synchronization, and delivery can be complex.

Simpler programming model but needs careful synchronization.

Use Cases

Distributed systems, cloud computing, IoT where nodes are geographically dispersed.

Multiprocessor systems, tightly coupled clusters.


Next Article
Resource Sharing in Distributed System

V

vishuvaishnav3001
Improve
Article Tags :
  • Operating Systems

Similar Reads

  • Features of Good Message Passing in Distributed System
    Message passing is the interaction of exchanging messages between at least two processors. The cycle which is sending the message to one more process is known as the sender and the process which is getting the message is known as the receiver. In a message-passing system, we can send the message by
    3 min read
  • Issues in IPC By Message Passing in Distributed System
    The sender sends a message that contains data and it is made in such a way that the receiver can understand it. The inter-process communication in distributed systems is performed using Message Passing. It permits the exchange of messages between the processes using primitives for sending and receiv
    5 min read
  • Resource Sharing in Distributed System
    Resource sharing in distributed systems is very important for optimizing performance, reducing redundancy, and enhancing collaboration across networked environments. By enabling multiple users and applications to access and utilize shared resources such as data, storage, and computing power, distrib
    7 min read
  • Marshalling in Distributed System
    A Distributed system consists of numerous components located on different machines that communicate and coordinate operations to seem like a single system to the end-user. External Data Representation: Data structures are used to represent the information held in running applications. The informatio
    9 min read
  • Multidatagram Messages in Distributed System
    In this article, we will go through the concept of Multidatagram messages in Distributed Systems in detail. In distributed systems, communication is carried out between processes by passing messages from one process to another. A message-passing system gives a collection of message-based IPC protoco
    3 min read
  • Process Management in Distributed System
    Process management in distributed systems involves coordinating tasks across multiple interconnected nodes. This article explores how processes are managed, synchronized, and controlled to ensure efficiency, fault tolerance, and scalability in distributed computing environments. Important Topics for
    10 min read
  • Logging in Distributed Systems
    In distributed systems, effective logging is crucial for monitoring, debugging, and securing complex, interconnected environments. With multiple nodes and services generating vast amounts of data, traditional logging methods often fall short. This article explores the challenges and best practices o
    10 min read
  • Causal Ordering of Messages in Distributed System
    Causal ordering of messages is one of the four semantics of multicast communication namely unordered, totally ordered, causal, and sync-ordered communication. Multicast communication methods vary according to the message's reliability guarantee and ordering guarantee. The causal ordering of messages
    4 min read
  • Replication Lag in Distributed Systems
    Replication lag in distributed systems refers to the delay that occurs when data changes in one part of a system and takes time to be reflected in other parts. In systems where data is copied across multiple servers or locations, maintaining consistency is crucial. However, due to factors like netwo
    12 min read
  • Latency in Distributed System
    Latency in distributed systems refers to the time delay between a request and a response in a network of interconnected computers. When multiple systems work together, this delay can affect performance and user experience. This explores the factors that contribute to latency, such as network speed,
    13 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences