0% found this document useful (0 votes)
10 views14 pages

DC Iat

The document discusses various aspects of distributed systems, including communication types, shared memory systems, and the importance of total and causal order in message delivery. It outlines a three-phase distributed algorithm for enforcing message order and highlights the significance of reliability aspects such as availability, integrity, and fault tolerance in different applications. Additionally, it provides real-world examples of FIFO message queues in banking and e-commerce scenarios.

Uploaded by

Reena V 12 A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views14 pages

DC Iat

The document discusses various aspects of distributed systems, including communication types, shared memory systems, and the importance of total and causal order in message delivery. It outlines a three-phase distributed algorithm for enforcing message order and highlights the significance of reliability aspects such as availability, integrity, and fault tolerance in different applications. Additionally, it provides real-world examples of FIFO message queues in banking and e-commerce scenarios.

Uploaded by

Reena V 12 A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

DC IAT-1 ANSWERS

PART A (10x2 = 12 marks)

1. Difference Between Synchronous and Asynchronous Communication Along with Buffering


Strategy (AU 2023)

• Synchronous Communication:

• In synchronous communication, the sender waits for the receiver to acknowledge


receiving the message before proceeding. Both sender and receiver are
synchronized.

• Buffering Strategy: Usually no or minimal buffering is required as both parties are


active at the same time.

• Asynchronous Communication:

• In asynchronous communication, the sender does not wait for an acknowledgment


and can send the message without knowing when it will be received.

• Buffering Strategy: Requires buffers to temporarily store messages until the receiver
is ready to process them.

2. Role of Shared Memory Systems (AU 2023)

• Shared memory systems provide a common memory space that multiple processes can
access and communicate through. This enables inter-process communication by reading and
writing to shared variables or memory locations, ensuring synchronization and data
consistency.

3. Scalar Time and Vector Time (AU 2023)

• Scalar Time: Uses a single counter (logical clock) to assign timestamps to events, ensuring a
partial order of events in a distributed system.

• Vector Time: Uses a vector of counters, one for each process, to track the causal relationship
between events and establish a more detailed order of events in distributed systems.

4. Relationship Between Independent Events e1 and e2 of Two Processes Occurring at the Same
Time (AU 2023)

• The relationship between e1 and e2 is concurrency. They occur independently without


affecting each other, meaning no causal relationship exists between them.

5. Features of a Distributed System

• Decentralization: No single point of control.

• Scalability: Can grow by adding more nodes.

• Fault Tolerance: Can continue operating despite some node failures.

• Concurrency: Multiple components execute simultaneously.

• Transparency: Hides the complexity of distribution from users.


6. Why Do We Need a Distributed System?

• Resource Sharing: Allows access to distributed resources such as databases, files, and
processing power.

• Reliability and Fault Tolerance: Distributed systems can provide redundancy and failover
mechanisms.

• Scalability: Easily scalable to handle more processes or users.

• Geographical Distribution: Supports applications spread across different geographical


locations.

7. What is Middleware?

• Middleware is software that provides common services and capabilities to applications


beyond what's offered by the operating system. It facilitates communication and data
management in distributed systems, acting as a bridge between different applications,
services, and platforms.

8. Purpose of the Snapshot Recording Algorithm

• The snapshot recording algorithm captures a consistent global state of a distributed system.
It is used for debugging, recovery, and analysis purposes, ensuring that all processes' states
and message channels are recorded at a specific instance without halting the system.

9. Define Total Order Execution

• Total order execution means that all processes in a distributed system agree on the same
sequence of events or message delivery order, ensuring consistency and synchronization
across the system.

10. Basic Properties of Vector Time

• Causality Tracking: Tracks causal relationships between events.

• Partial Ordering: Provides a partial order of events across processes.

• Event Comparison: Two vector timestamps can be compared to determine whether events
are causally related, concurrent, or ordered.

• Size: The vector time grows in size with the number of processes in the system. Each process
maintains a vector with entries for all processes.

PART C

10)b)Three-phase distributed algorithm for enforcing total and causal order of messages in
distributed systems.

Three-Phase Distributed Algorithm for Enforcing Total and Causal Order

In distributed systems, ensuring both total order and causal order for messages exchanged between
processes is critical for maintaining consistency and correctness. The three-phase distributed
algorithm is designed to enforce these message orders in a closed group of processes, ensuring that
all processes in the group receive messages in the same sequence (total order) and respect cause-
effect relationships (causal order).

Key Concepts:

• Total Order: All messages are received in the same order by all processes, regardless of when
and from where they were sent.

• Causal Order: Messages that are causally related (i.e., one message influences or depends
on another) are received in the correct cause-and-effect order.

Overview of the Three-Phase Distributed Algorithm

The algorithm operates in three distinct phases, where messages are assigned timestamps, these
timestamps are negotiated, and a final order is agreed upon by all processes. The goal is to establish
a consistent message delivery sequence that adheres to both total and causal ordering rules.

Phase 1: Message Multicast (Initiation by Sender)

• A process (sender) multicasts a message (M) to all processes in the group.

• The message is tagged with a locally unique identifier (a message ID) and a tentative
timestamp (based on the sender's local clock).

• The timestamp reflects the sender's current logical or physical time and helps establish an
initial ordering of the message.

Phase 2: Tentative Timestamp Proposal by Receivers

• Upon receiving the message, each process checks the timestamp in the message and
compares it with its own local time.

• Each process generates a tentative timestamp for the message, ensuring that its timestamp
reflects the current state of the process.

• This timestamp is typically the greater of the received timestamp and the process’s current
clock time (incremented).

• The receivers then send their proposed timestamp back to the sender.

• The sender waits to receive tentative timestamps from all group members before proceeding
to the next phase.

Phase 3: Final Timestamp Assignment

• Once the sender receives all proposed timestamps, it computes the maximum of all
proposed timestamps. This maximum timestamp becomes the final timestamp for the
message.

• The sender then multicasts this final timestamp to all group members, confirming the
delivery order.

• Each process, upon receiving the final timestamp, can now mark the message
as deliverable and deliver it in the agreed order.
Operations of the Algorithm:

1. Sender’s Role:

• Multicast Message: The sender initiates the communication by sending a message with its
local timestamp.

• Collect Tentative Timestamps: It collects tentative timestamps from all processes.

• Final Timestamp Assignment: The sender computes the highest proposed timestamp and
multicasts the final timestamp to all receivers, ensuring that the message is delivered in the
same order across all processes.

2. Receiver’s Role:

• Propose Tentative Timestamp: Upon receiving the message, the receiver checks its local
clock and proposes a timestamp. The proposed timestamp ensures that messages are
processed in causal order.

• Wait for Final Timestamp: After sending the tentative timestamp, the receiver waits for the
final timestamp from the sender.

• Deliver Message: Once the final timestamp is received, the message is marked deliverable,
and the receiver delivers the message in the proper order.

Example: Message Exchanges Between Multiple Processes

Consider a distributed system with four processes: P1, P2, P3, and P4. Each process follows the
three-phase distributed algorithm to ensure total and causal message order.

Scenario:

• P1 sends a message M1 to processes P2, P3, and P4 with a timestamp of 5.

• P2 sends another message M2 to P3 and P4 with a timestamp of 8.

Here’s how the algorithm handles the message exchange:

Phase 1: Initial Multicast

• P1 multicasts M1 with a tentative timestamp of 5 to P2, P3, and P4.

• P2 sends M2 with a timestamp of 8 to P3 and P4.

Phase 2: Tentative Timestamp Proposal

• P2 receives M1 and proposes a new timestamp of 6 (its local clock is 5, and it increments it
to 6).

• P3 and P4 also receive M1 and propose timestamps of 9 (their clocks are ahead).

• P3 and P4 receive M2 and propose timestamps of 9 and 10, respectively.

Phase 3: Final Timestamp Assignment


• P1 collects the timestamps for M1: 6 (from P2), 9 (from P3), and 9 (from P4). The final
timestamp is 9.

• P2 collects the timestamps for M2: 9 (from P3) and 10 (from P4). The final timestamp is 10.

Message Delivery:

• M1 with the final timestamp of 9 is delivered before M2 (timestamp 10), ensuring total
order.

• The causal order is respected because P2's proposal for M1 considered its local clock and
updated it before sending M2.

Total and Causal Order Enforcement:

The algorithm ensures both total order and causal order:

• Total Order: All processes deliver messages in the same final order determined by the final
timestamps. In the example, M1 is delivered before M2 across all processes.

• Causal Order: Causal relationships between messages are respected. For example,
if M1 caused M2, the algorithm guarantees that M1 will always be delivered before M2.

Advantages of the Three-Phase Distributed Algorithm:

1. Consistency Across Processes: Ensures that all processes deliver messages in the same order,
which is crucial in applications like banking systems where the order of transactions must be
consistent across all branches.

2. Causal Dependency Management: The algorithm respects causal dependencies between


messages, making it ideal for applications where one message's outcome affects the content
or timing of the next message (e.g., in collaborative editing systems like Google Docs).

3. Fault Tolerance: Even if some messages are delayed or received out of order, the algorithm
ensures that the final delivery order remains consistent, making it suitable for distributed
systems with unreliable networks.

Applications of the Algorithm:

1. Distributed Databases:

• In systems where transactions need to be committed in the same order across


multiple replicas (e.g., a banking system with globally distributed branches), this
algorithm ensures consistency by delivering transactions in total order.

2. Multiplayer Online Games:

• In real-time strategy or multiplayer games, it is crucial to maintain the correct


sequence of actions performed by players. For example, one player's attack must be
processed before another player's defense, ensuring consistency in game state
across all players.
3. Collaborative Work Environments:

• Tools like shared document editing (e.g., Google Docs or Microsoft Teams) require
that changes made by users are processed in the same order for all participants. The
three-phase algorithm ensures consistent ordering of edits and updates.

Conclusion:

The three-phase distributed algorithm is essential for enforcing both total and causal order in
message delivery across distributed systems. Its ability to guarantee consistent message ordering
makes it a fundamental approach for ensuring the reliability and correctness of distributed
applications like banking systems, multiplayer games, and collaborative tools. By using tentative
timestamps and negotiating final timestamps, the algorithm ensures that all processes receive
messages in the same sequence, respecting causal dependencies and maintaining system-wide
consistency.

9a) Three Aspects of Reliability in Distributed Systems

Reliability in distributed systems can be broken down into three main aspects:

1. Availability

• This refers to the system's ability to be operational and accessible when needed.

• A system is highly available if it can function continuously, minimizing downtime.

2. Integrity

• This ensures that the system's data remains accurate and consistent, even in the
face of concurrent access or system failures.

• Data integrity guarantees that unauthorized access or errors do not corrupt the
information stored and processed by the system.

3. Fault Tolerance

• Fault tolerance is the system's ability to continue functioning correctly even when
parts of the system fail.

• A fault-tolerant system is designed to handle hardware or software failures


without disrupting service.

Can These Aspects Be Ordered Differently Based on Application Requirements?

Yes, the importance of these aspects can vary depending on the application. Different systems
prioritize reliability aspects differently based on their specific use cases. Below are examples of
applications where each aspect is more critical than the others:

1. Availability as the Most Important Aspect


Example: E-Commerce Websites (Amazon, eBay)

• Justification: In e-commerce platforms, availability is crucial because downtime directly


impacts revenue and user experience. If the site is unavailable, customers cannot make
purchases, which results in lost sales and decreased customer trust.

• Prioritization:

• Availability (highest priority): The website must be accessible 24/7.

• Fault Tolerance: The system should continue working even if some components fail
(e.g., one server going down should not crash the entire site).

• Integrity (lower priority): Though important, occasional minor data inconsistencies


(such as delayed updates on stock) are tolerable in this context.

2. Integrity as the Most Important Aspect

Example: Banking and Financial Systems

• Justification: In banking applications, data integrity is paramount because incorrect data


(e.g., account balances) could result in significant financial losses and legal consequences.
Every transaction must be accurate and reflect the true state of a customer's account.

• Prioritization:

• Integrity (highest priority): Transactions and account balances must always be


accurate.

• Fault Tolerance: The system must ensure that operations continue even in the
event of hardware or software failures, but availability can be secondary as long as
no data corruption occurs.

• Availability (lower priority): Short downtimes (for maintenance or fault recovery)


may be acceptable, but integrity cannot be compromised.

3. Fault Tolerance as the Most Important Aspect

Example: Air Traffic Control Systems

• Justification: In critical systems like air traffic control, fault tolerance is the top priority.
Even in the event of hardware failures or power outages, the system must continue
functioning to ensure safety.

• Prioritization:

• Fault Tolerance (highest priority): The system must continue to operate seamlessly,
ensuring that no critical operations are interrupted.

• Availability: The system must always be accessible, but its ability to withstand
failures (fault tolerance) is what keeps it running.
• Integrity (lower priority): Though important, minor data delays or temporary
inconsistencies can be tolerated as long as the system remains operational.

Conclusion:

The order of importance for the three aspects of reliability—availability, integrity, and fault
tolerance—depends on the application's requirements. For example, e-commerce platforms
prioritize availability, financial systems emphasize data integrity, and safety-critical systems like air
traffic control require fault tolerance as their top concern. By understanding the specific demands
of each application, system designers can allocate resources and design their architectures to
prioritize the most critical aspect of reliability.

PART B

8A) FIFO Message Queue: Real-Time Scenario

Definition:

• FIFO (First In, First Out) message queue refers to a method of processing where the first
message or transaction sent into the queue is the first one to be processed. It maintains
the sequence of messages, which is critical in systems requiring ordered message delivery.

Real-Time Scenario: Banking Systems

• Scenario:

• In a distributed banking system, customers may initiate transactions


like withdrawals, deposits, or transfers. These operations need to be processed in
the exact sequence they were submitted to ensure data consistency across
distributed databases. If the sequence is disrupted, it could lead to incorrect bank
balances, which is unacceptable for financial transactions.

• How FIFO Works:

• In the banking example, each customer request (message) is placed into a FIFO
queue. The first request (say a deposit) is processed first, followed by the next one
(say a withdrawal).

• Example: If a customer deposits $100, then withdraws $50, these transactions


must happen in order. A FIFO queue ensures that the withdrawal doesn't happen
before the deposit, avoiding an overdraft situation.

Other Real-World Examples of FIFO Message Queues:

1. Order Processing in E-Commerce:


• In online shopping systems, orders placed by customers are queued in the order
they are received. Each order is processed one by one, ensuring fair handling of
customer requests.

2. IoT (Internet of Things) Devices:

• In IoT applications, sensor data is often time-sensitive. A FIFO queue ensures that
the oldest sensor data is processed first, ensuring that time-dependent data is
handled in sequence.

Advantages of FIFO:

• Ordered Message Delivery: Ensures the system processes requests in the exact order they
are sent, preventing data inconsistencies.

• Simplicity: Easy to implement and understand, particularly in distributed systems.

• Predictability: Ensures fairness, as each message is processed in the same order it was
received.

Disadvantages:

• Scalability: In high-load systems, queues can become long, leading to delays.

• No Priority Handling: FIFO does not prioritize urgent tasks, meaning all tasks are treated
equally, regardless of importance.

Snapshot Algorithm for FIFO Channels

Definition:

• A snapshot algorithm is used in distributed systems to capture a consistent global state


across multiple processes. The Chandy-Lamport Snapshot Algorithm is one of the most
common algorithms for recording snapshots over FIFO channels.

Purpose of Snapshot Algorithm:

• In distributed systems, it is essential to capture a consistent state across multiple processes


to understand the system’s global behavior or recover from failures. The snapshot provides
a "picture" of all processes and the messages in transit at a specific moment.

Chandy-Lamport Snapshot Algorithm for FIFO Channels

How It Works:

The algorithm relies on markers to distinguish which messages to include in the snapshot and
ensures that no message is missed during the recording of the system state.

1. Initiating the Snapshot:

• One process initiates the snapshot by recording its local state (e.g., the balance of
an account in a banking system).
• After recording its state, the process sends a marker along all of its outgoing
channels to notify other processes that it is taking a snapshot.

• The process continues to send and receive messages after the marker is sent.

2. Receiving the Marker:

• When another process receives the marker for the first time:

1. It records its local state.

2. It records the state of the incoming channel as empty because no messages


sent before the marker can be in transit.

3. It forwards the marker to all outgoing channels.

• If the process receives another marker on a different channel after recording its
state, it only records the messages received between the local state recording and
the marker arrival.

3. Recording Channel State:

• For each channel, the algorithm ensures that only messages sent before the
marker was sent are recorded in the snapshot. Messages sent after the marker are
excluded.

Example:

Consider two banking processes P1 and P2:

• P1 starts a snapshot and records its current state (account balance). It then sends
a marker to P2.

• P2 receives the marker, records its balance, and marks its incoming channel as empty.

• Any messages sent between P1 and P2 before the marker are included in the snapshot, but
those sent after the marker are excluded.

Snapshot Algorithm for FIFO Channels - Detailed Steps:

1. Recording Local State:

• When a process initiates the snapshot, it records its current local state (e.g.,
account balance in banking).

2. Sending Markers:

• The process sends markers to all outgoing channels to inform other processes of
the snapshot.

3. Recording Channel States:

• For each incoming channel, the process waits until it receives a marker. Until the
marker is received, all incoming messages on that channel are considered part of
the state. After receiving the marker, the process considers the channel state as
empty.

4. Termination:
• The snapshot is complete when all processes have recorded their local states and
received a marker on each incoming channel.

Advantages of Chandy-Lamport Algorithm:

• Simplicity: Works efficiently on FIFO channels, simplifying the process of recording


consistent global states.

• Non-intrusive: The system does not need to be paused or stopped for the snapshot to be
taken.

Disadvantages:

• Communication Overhead: Sending markers along every channel may create additional
overhead in high-communication systems.

• Delayed Snapshot: If channels are slow, the snapshot process may take longer to complete.

Real-Life Application of Snapshot Algorithm:

In a distributed database system, a snapshot algorithm can be used to ensure consistent backups.
For example, a snapshot could record the current state of all account balances in a banking system.
If one server crashes, the snapshot provides a consistent view of all transactions at the moment
before the crash, ensuring that no data is lost or duplicated.

Conclusion:

In systems where message order is crucial, like in banking, the FIFO message queue ensures that
transactions are processed in the correct sequence. The Chandy-Lamport Snapshot
Algorithm effectively records the global state in distributed systems by using markers and works
efficiently in FIFO channels. Together, FIFO queues and snapshot algorithms maintain consistency,
integrity, and reliability in distributed computing environments.

7A) Message Passing Systems in Distributed Computing

Definition:

• Message Passing is a communication method used in distributed systems where processes


exchange data in the form of messages without shared memory.

Key Features:

• Processes communicate by sending and receiving messages.

• Communication can be synchronous (blocking) or asynchronous (non-blocking).

• Useful for geographically distributed systems.

Advantages of Message Passing:

• No need for shared memory.


• Easier to implement in distributed environments.

• Supports both synchronous and asynchronous communication.

Disadvantages:

• Higher latency compared to shared memory.

• Complexity in error handling and message synchronization.

Message-Oriented Middleware (MOM)

Definition:

• MOM is software that facilitates message exchange between distributed systems or


components. It abstracts the complexity of network communication by providing a standard
interface for message passing.

Key Functions of MOM:

• Asynchronous Communication: It allows processes to exchange messages without waiting


for the receiver to be ready.

• Decoupling of Components: Sender and receiver need not interact directly, enabling
flexibility in system design.

• Reliability: Ensures that messages are delivered reliably even in case of failures.

Types of Message-Oriented Middleware:

1. Point-to-Point (P2P) Systems:

• Mechanism:

• Messages are sent from one sender to one receiver through a queue.

• The sender pushes the message into the queue, and the receiver retrieves it.

• Example:

• ActiveMQ, RabbitMQ.

• Use Case:

• A ticket booking system where each request (message) is processed exactly once.

Advantages:

• Guaranteed delivery to a single receiver.

• Easier error handling as each message is consumed once.

Disadvantages:

• Limited scalability due to single receiver.

2. Publish/Subscribe (Pub/Sub) Systems:

• Mechanism:
• Messages are published to topics, and multiple subscribers receive messages from
the topic.

• This model decouples the message producer from consumers.

• Example:

• Apache Kafka, JMS.

• Use Case:

• Newsfeed systems where multiple users subscribe to a topic and receive updates.

Advantages:

• Supports multiple receivers (scalable).

• Decouples sender and receiver, providing flexibility in communication.

Disadvantages:

• Message order is not guaranteed.

• More complex to manage subscribers.

Role of MOM in Distributed Computing:

• Enhancing Scalability: MOM allows different components of distributed systems to scale


independently, as they don't need to communicate synchronously.

• Fault Tolerance: By using message queues and topics, MOM can manage failed components
without losing data, as messages are stored and resent when the system is restored.

• Use of Asynchronous Messaging: Applications in cloud environments or microservices


benefit from asynchronous messaging, where processes can send and receive messages
independently of each other.

Example of MOM:

Consider an e-commerce system:

• When a customer places an order (message), it goes to an order processing queue (Point-to-
Point model).

• After processing, a notification service (using Pub/Sub) sends order status updates to all
subscribers (warehouse, customer, delivery team).

Conclusion:

Message-oriented middleware is vital for building scalable, fault-tolerant distributed systems. By


abstracting the complexities of direct communication between systems, it allows developers to focus
on building robust and efficient distributed applications. Examples like ActiveMQ and Kafka illustrate
the flexibility and reliability MOM offers.
IN TEXTBOOK REFER TOPICS : ( TO INCUDE DIAGRAMS ETC ) :

1. Message Passing Systems and Middleware:

• Topic Reference: Section 1.5 (Chapter 1) .

2. FIFO Message Queue and Snapshot Algorithm:

• Topic Reference: 4.3 (Chapter 4) .

3. Three Aspects of Reliability (Availability, Integrity, Fault Tolerance):

• Topic Reference: in Section 1.4(Chapter 1) .

4. Three-Phase Distributed Algorithm for Total and Causal Order:

• Topic Reference: Section 6.6 (Chapter 6) .

You might also like