Distributed System
Distributed System
Q1 What are the general characteristics of inter-process communication? What are various types
of synchronous and asynchronous communication in IPC? Why does blocking receive have no
disadvantages in Java?
Interprocess Communication (IPC) is a mechanism that allows different processes to exchange data
and coordinate their actions in a distributed system.
IPC is important because processes in a distributed system run separately but need to communicate
to perform tasks together.
(iv) Reliability
(v) Ordering
Messages may need to be received in the same order they were sent.
(vi) Security
(vii) Scalability
(viii) Transparency
A process should communicate without worrying about where the other process is located.
1. Synchronous Communication
2. Asynchronous Communication
A) Synchronous Communication
The sending process may wait until the receiver gets the message.
Sender sends message and waits until message is received or copied safely.
Features:
B) Asynchronous Communication
In asynchronous communication, sender and receiver do not need to wait for each other.
Features:
Faster communication.
Slower Faster
Normally, waiting may seem like a disadvantage, but in Java it is not a disadvantage because:
Java sockets and streams are designed to work efficiently with blocking receive.
Event Timestamp
A 1
Send Message 2
Receive Message 3
Thus:
A → Send → Receive
This shows correct ordering of events.
7. Limitations of Lamport Clock
Although useful, Lamport clock has some limitations:
(i) Cannot Detect Concurrent Events
If two events happen independently at the same time, Lamport clock cannot tell that they
are concurrent.
It only gives timestamps.
(ii) Timestamp Order Does Not Always Mean Causality
If:
Timestamp(A) < Timestamp(B)
It does not always mean A caused B.
Only logical order is shown.
(iii) Different Events Can Have Same Relation Ambiguity
Extra process ID may be needed to break ties.
(iv) No Real Physical Time
Lamport clock gives logical time, not actual clock time.
Q3 Explain external data representation (XDR), marshalling and unmarshalling. Why is XDR
required? Discuss in brief the three alternative approaches.
1. External Data Representation (XDR)
XDR (External Data Representation) is a standard format used to represent data in a
machine-independent way in distributed systems.
Different computers may have:
Different operating systems
Different data formats
Different byte ordering
So, data sent from one machine may not be understood correctly by another machine.
XDR solves this problem by converting data into a common standard format before
transmission.
Simple Definition:
XDR = Common language for data exchange between different computers
2. Need for XDR (Why is XDR required?)
In distributed systems, different machines may represent data differently.
Example:
One machine may store integer as:
Big-endian
Another machine may store integer as:
Little-endian
If data is sent directly, the receiver may interpret it incorrectly.
XDR is required because:
(i) Machine Independence
Allows communication between different machines.
(ii) Standard Data Format
Converts data into a common format.
(iii) Data Portability
Data can move between systems safely.
(iv) Correct Interpretation
Receiver correctly understands data.
(v) Supports Heterogeneous Systems
Useful when systems use different architectures.
3. Marshalling
Marshalling is the process of collecting data and converting it into a standard format (such
as XDR) before sending it over a network.
It prepares data for transmission.
Definition:
Marshalling = Convert internal data → transferable format
Example:
Suppose data:
Integer = 10
String = "Hello"
Before sending:
These are converted into standard byte format.
Steps in Marshalling:
1. Collect data
2. Convert to standard format
3. Pack into message
4. Send over network
4. Unmarshalling
Unmarshalling is the reverse process.
It converts received data from standard format back into machine’s local format.
Definition:
Unmarshalling = Convert received format → local machine format
Steps:
1. Receive message
2. Extract data
3. Convert to local format
4. Use the data
5. Example of Marshalling and Unmarshalling
Suppose:
Client sends:
Number = 25
At sender:
25 → converted into XDR format → sent
(Marshalling)
At receiver:
XDR format → converted back into 25
(Unmarshalling)
6. Three Alternative Approaches to Data Representation
There are three alternatives for handling data representation in distributed systems.
Approach 1: Receiver Makes No Conversion
Sender sends data in its own format.
Receiver tries to interpret directly.
Problem:
Works only if both machines are same.
Fails in heterogeneous systems.
Disadvantage:
Not practical.
Approach 2: Receiver Converts Data
Sender sends data in its own format.
Receiver knows sender’s format and converts it.
Advantage:
Some flexibility
Disadvantage:
Receiver must understand many machine formats
Complex
Approach 3: Use Standard External Representation (XDR)
Sender converts data to a common format
Receiver converts from common format to local format
Process:
Sender → XDR → Network → Receiver
Advantage:
Machine independent
Easy communication
Most widely used
Disadvantage:
Extra conversion overhead
Q4 Discuss the problem of clock synchronization in distributed operating systems.
Illustrate the Berkeley’s clock synchronization algorithm with neat diagram and the
drawback of Network Time Protocol (NTP).
1. Introduction
In a distributed system, multiple computers work together but each computer has its own
local clock.
These clocks are based on hardware oscillators and may run at slightly different speeds.
As a result, clocks on different machines may show different times.
This creates the clock synchronization problem.
2. Why is Global Time Impossible in Distributed Systems?
A global clock means all machines have exactly the same time.
In distributed systems, this is impossible because:
(i) No Shared Physical Clock
Each computer has its own hardware clock.
There is no single clock shared by all systems.
(ii) Clock Drift
Hardware clocks do not run at exactly the same speed.
One clock may run fast, another slow.
This causes clock drift.
(iii) Message Transmission Delay
Synchronization messages take time to travel over the network.
Delay is not constant.
So exact time cannot be known.
(iv) Unpredictable Network Delay
Network traffic changes.
Message delay may vary.
Thus perfect synchronization is impossible.
Conclusion:
Because of clock drift + network delay + separate clocks, exact global time cannot be
achieved.
Only approximate synchronization is possible.
3. Why is Clock Synchronization Necessary?
Clock synchronization is important because distributed systems need correct event timing.
Uses of synchronization:
(i) Event Ordering
To know:
Which event happened first
Correct sequence of actions
(ii) File Updates
Used in:
File systems
Database transactions
To avoid conflicts.
(iii) Logging and Monitoring
System logs need synchronized timestamps.
(iv) Security
Authentication systems use time-based verification.
(v) Distributed Applications
Banking, airline reservation, cloud systems need synchronized clocks.
4. Design Requirements for Clock Synchronization System
A synchronization system should satisfy:
(i) Accuracy
Clocks should be as close as possible.
(ii) Reliability
Should work even if some machine fails.
(iii) Scalability
Should work for small and large networks.
(iv) Fault Tolerance
Failure of one node should not crash synchronization.
(v) Low Communication Cost
Should not send too many synchronization messages.
(vi) Security
Synchronization messages should be protected.
(vii) Fast Convergence
System should quickly synchronize clocks.
5. Active Time Server Based Centralized Clock Synchronization Algorithm
This is a centralized method.
A special machine called Time Server keeps the correct time.
All other machines synchronize with it.
Working:
Step 1: Client sends request to Time Server.
Step 2: Server replies with current time.
Step 3: Client estimates network delay.
Step 4: Client updates its clock.
Diagram:
Client 1 ----\
Client 2 ----- > Time Server
Client 3 ----/
Formula:
Client sets:
New Time = Server Time + Estimated Delay
Advantages
Simple
Easy to implement
Accurate in small systems
Disadvantages
Single point of failure
Server overload possible
6. Problem of Clock Synchronization in Distributed Operating Systems
Main problems:
No global clock
Clock drift
Variable network delay
Machine failures
Inconsistent event ordering
Hence synchronization algorithms are needed.
Q5 What is NTP? With the help of a diagram, describe how NTP works.
NTP (Network Time Protocol) is a protocol used to synchronize the clocks of computers
over a network or the Internet.
It helps all computers maintain approximately the same correct time.
NTP uses UTC (Universal Coordinated Time) as the standard reference time.
2. Need for NTP
In distributed systems:
Each computer has its own clock
Clocks may run fast or slow
Network applications need same time
Without synchronization:
Event ordering becomes wrong
Logs become inconsistent
Transactions may fail
So NTP is used.
Symbol Meaning
Master 10:00
Slave 1 10:02
Slave 2 09:58
Slave 3 10:01
Machine Adjustment
Slave 1 -2 min
Slave 2 +2 min
Slave 3 -1 min
Q7 What is the purpose of Message Passing Interface? Illustrate the architectural model
for MPI using send and receive primitives. (appears multiple times)
MPI (Message Passing Interface) is a standard communication library used in parallel and
distributed computing.
It allows different processes running on different processors or computers to communicate
with each other by sending and receiving messages.
Simple Definition:
MPI = A standard for communication between processes using message passing
2. Purpose of MPI
In distributed systems, each process runs independently and has its own memory.
One process cannot directly access another process’s memory.
Therefore, MPI is used to exchange data through messages.
Main Purposes of MPI
(i) Process Communication
MPI allows one process to send data to another process.
(ii) Parallel Processing
Multiple processors can work on parts of a task simultaneously.
(iii) Synchronization
Processes coordinate and exchange results.
(iv) High Performance Computing
MPI is used in supercomputers and clusters.
(v) Portability
MPI programs work on many hardware systems.
3. Architectural Model of MPI (Using Given Diagram)
The given figure shows the basic MPI architecture.
Explanation of Diagram:
CPU Core 1 runs Process 0
CPU Core 2 runs Process 1
Each process has:
o Its own Memory
o Its own Data
A message is sent from Process 0 to Process 1
This communication happens through MPI.
Diagram Representation
What the Diagram Shows
Process 0 contains data in its local memory
Process 0 uses MPI_Send()
Message travels through communication channel
Process 1 receives data using MPI_Recv()
Received data is stored in Process 1 memory
This is the message-passing model of MPI
4. Send and Receive Primitives in MPI
MPI communication is mainly based on two primitives:
(i) MPI_Send()
Used to send data from one process to another.
Syntax:
MPI_Send(data, count, datatype, destination, tag, communicator)
Parameters:
data → message to send
count → number of items
datatype → type of data
destination → receiver process
tag → message identifier
communicator → communication group
(ii) MPI_Recv()
Used to receive data.
Syntax:
MPI_Recv(data, count, datatype, source, tag, communicator, status)
Parameters:
data → received message
source → sender process
Other parameters same as send
5. Working of MPI Communication
Step 1
Process 0 prepares data in memory.
Step 2
Process 0 calls MPI_Send()
Step 3
Data is sent as a message.
Step 4
Process 1 calls MPI_Recv()
Step 5
Data is stored in Process 1 memory.
6. Point-to-Point Communication in MPI
The communication shown in the diagram is called point-to-point communication.
Meaning:
One sender → One receiver
Diagram:
Process 0 ---- MPI_Send() ----> Process 1
Process 1 <--- MPI_Recv() ---- Process 0
Features:
Direct communication
One sender
One receiver
Uses send and receive primitives
1. MPI_Ssend (Synchronous Send)
MPI_Ssend is a synchronous send operation.
The sender sends a message and waits until the receiver starts receiving it.
Communication completes only when receiver is ready.
Advantage:
Safe and reliable communication
Disadvantage:
Slower because sender waits
Memory Tip:
Ssend = Synchronous = Sender Waits
2. MPI_Bsend (Buffered Send)
MPI_Bsend is a buffered send operation.
The message is first copied into a buffer memory
Sender continues immediately without waiting for receiver
Advantage:
Faster communication
Disadvantage:
Requires extra buffer memory
Memory Tip:
Bsend = Buffer = Store first, send later
3. MPI_Rsend (Ready Send)
MPI_Rsend is a ready send operation.
Sender sends message only if receiver is already ready
If receiver is not ready, an error may occur
Advantage:
Faster than normal send
Disadvantage:
Unsafe if receiver is not prepared
Memory Tip:
Rsend = Receiver Ready
4. MPI_Isend (Non-blocking / Immediate Send)
MPI_Isend is a non-blocking send operation.
Sender starts sending message
Sender continues execution immediately
Does not wait for completion
Advantage:
Better performance
Supports parallel work
Disadvantage:
More complex to manage
Memory Tip:
Isend = Immediate = No Waiting
Q8 Discuss the purpose of overlay network. Describe in brief, any three types of Overlay.
An Overlay Network is a virtual network built on top of an existing physical network.
In an overlay network:
Nodes are connected through logical links
These logical links use the underlying Internet or physical network to communicate
So, the overlay creates a network over another network.
Simple Definition:
Overlay Network = Virtual network built on top of physical network
2. Purpose of Overlay Network
Overlay networks are used to improve communication and provide extra network services.
Main Purposes:
(i) Easy Communication
Provides direct logical communication between nodes.
(ii) Resource Sharing
Helps share files, services, and applications between users.
(iii) Improved Routing
Can choose better paths than physical network routing.
(iv) Scalability
Supports large distributed systems.
(v) Fault Tolerance
If one path fails, another path can be used.
(vi) Supports Special Applications
Used in:
Peer-to-peer systems
VPN
Content Delivery Networks
Distributed systems
3. Types of Overlay Networks
There are many types of overlay networks.
Any three are:
A) Peer-to-Peer (P2P) Overlay Network
In this type:
Each node acts as both client and server
Nodes directly communicate and share resources
Example:
BitTorrent
Skype (older architecture)
Features:
No central server
Resource sharing
Scalable
Diagram:
Node A ↔ Node B ↔ Node C
↕ ↕ ↕
Node D ↔ Node E ↔ Node F
Advantage:
Distributed and scalable
B) Structured Overlay Network
In this type:
Nodes are organized in a structured manner
Uses special algorithms for searching data
Examples:
Distributed Hash Table (DHT)
Chord
Features:
Organized node structure
Fast searching
Efficient routing
Example:
Each node stores data using a key.
Advantage:
Quick data lookup
C) Unstructured Overlay Network
In this type:
Nodes connect randomly
No fixed structure
Examples:
Early P2P systems like Gnutella
Features:
Easy to join/leave
Search by broadcasting queries
Advantage:
Simple to build
Disadvantage:
Search can be slow
D) Hybrid Overlay Network (Extra)
In this type:
Combines central server and peer-to-peer model
Example:
Modern Skype architecture
Advantage:
Better performance
Components in the Skype Diagram
1. Skype Login Server (Top)
The Skype server at the top is the central login server.
It performs authentication (checks username and password).
Once authentication is complete, it does not handle the actual call.
Function: User authentication only.
2. Skype Clients (Blue small S nodes)
The small blue S symbols represent ordinary Skype clients/users.
These are normal devices used for:
o Voice calls
o Video calls
o Chat
Function: End users in the Skype network.
3. Super Nodes (Yellow large S nodes)
The yellow large S symbols represent Skype Super Nodes.
These are powerful systems with:
o Public IP address
o High bandwidth
o Better processing capability
Functions:
Maintain user information
Route traffic between clients
Help establish communication
Working of Skype Overlay Architecture
Step 1: Authentication
A Skype client first contacts the Login Server.
The login server verifies the username and password.
Shown in diagram: Authentication arrow toward Skype server.
Step 2: Client Connects to Super Node
After login, the client connects to a nearby Super Node.
Super nodes keep track of online users.
Step 3: Communication Between Users
Case 1: Direct Connection
If two Skype clients can connect directly:
Client A ↔ Client B
Communication happens directly in peer-to-peer mode.
Case 2: Through Super Nodes
If direct communication is not possible (NAT/firewall):
Client A → Super Node → Super Node → Client B
Super nodes route the call/data.
Benefits (Advantages) of Overlay Network
1. Scalability – Easy to add new nodes/users without changing the physical network.
2. Efficient Routing – Data can be routed through alternate paths.
3. Fault Tolerance – If one node fails, communication can continue through another
node.
4. Flexibility – Works on top of existing Internet infrastructure.
5. Cost Effective – No need to build a separate physical network.
6. Supports P2P Communication – Enables direct communication between users.
7. Load Sharing – Traffic can be distributed among multiple nodes.
Q9 What are the two important properties of token-based approach? Explain token-ring
algorithm to achieve mutual exclusion in a distributed system.
In a distributed system, many processes may want to use a shared resource (printer, file,
database, etc.).To avoid conflicts, mutual exclusion is required.
A token-based approach uses a special message called a token.
Rule:
A process can enter the critical section (CS) only if it has the token.
Without token, it must wait.
Simple Definition:
Token = Permission to enter critical section
2. Two Important Properties of Token-Based Approach
(i) Uniqueness of Token
There must be only one token in the system.
Why?
If more than one token exists, multiple processes may enter critical section at the
same time.
This breaks mutual exclusion.
Result:
One token → One process in critical section
(ii) Token Availability / No Token Loss
The token must always be available in the system.
Why?
If token is lost, no process can enter critical section.
System stops working.
Result:
Token should circulate safely
3. Token-Ring Algorithm
Token-Ring is a distributed mutual exclusion algorithm based on token passing.
Processes are arranged in a logical ring.
A token moves from one process to the next in a circular order.
Only the process holding the token can enter the critical section.
4. Neat Diagram of Token-Ring Algorithm
P1 → P2
↑ ↓
P5 P3
← P4 ←
(Token moves in circular direction)
5. Working of Token-Ring Algorithm
Step 1: Ring Formation
All processes are arranged in a logical ring.
Example:
P1 → P2 → P3 → P4 → P5 → P1
Step 2: Token Circulates
A special token continuously moves in ring order.
Example:
P1 passes token to P2, P2 to P3, etc.
Step 3: Process Requests Critical Section
Suppose P3 wants to enter critical section
It waits until token arrives.
Step 4: Process Enters Critical Section
When P3 receives token:
It enters critical section
Uses shared resource
No other process can enter because only P3 has token.
Step 5: Token Passed to Next Process
After completing work:
P3 passes token to P4
Token continues circulating.
6. Example
Suppose ring:
P1 → P2 → P3 → P4
Current token at P2
P2 uses critical section
Passes token to P3
P3 enters critical section if needed
Then token moves to P4
Thus mutual exclusion is maintained.
7. Advantages of Token-Ring Algorithm
(i) Guaranteed Mutual Exclusion
Only token holder enters critical section.
(ii) No Starvation
Every process gets token in order.
(iii) Fairness
Processes get equal chance.
(iv) No Need for Broadcast Messages
Only token passing required.
8. Disadvantages of Token-Ring Algorithm
(i) Token Loss Problem
If token is lost, system stops.
(ii) Process Failure Problem
If one process fails, ring breaks.
(iii) Delay
A process may wait for token even if critical section is free.
Q10 Explain the goal of an Election algorithm. Illustrate the bully algorithm using
appropriate diagrams.
In a distributed system, one process is often selected as a coordinator (leader).
The coordinator performs special tasks such as:
Resource management
Synchronization
Process coordination
Failure handling
If the coordinator fails, the system must select a new coordinator.
This process is done by an Election Algorithm.
Simple Definition:
Election Algorithm = Method used to select a new coordinator in a distributed system
a 1 First event
c 4 Next event
d 5 Next event
g 10 Next event
Process P2
Event Timestamp
h 1
i 2
j 4
k 5
l 8
Process P3
Event Timestamp
m 2
n 3
o 7
p 8
q 10
Process P4
Event Timestamp
r 2
s 3
t 6
u 7
Q12 Consider the Figure 1 that shows four processes (P1, P2, P3, P4) with events a, b, c,...
and messages communicating between them. Assume that initial logical clock values are
all initialized to 0. List the Lamport timestamps for each event shown in Figure 1. Assume
that each process maintains a logical clock as a single integer value as a Lamport clock.
Provide timestamps for each labeled event.
Step-by-Step Timestamps
Initial clocks of all processes:
P1 = 0, P2 = 0, P3 = 0, P4 = 0
Process P1 (a, b, c, d, e, f, g)
a = 1 (first event, sends to r)
b = 2 (receives from h=1 → max(1,1)+1 = 2)
c=3
d=4
e = 7 (receives from u=6 → max(4,6)+1 = 7)
f = 8 (receives from p=5 → max(7,5)+1 = 8)
g=9
Process P2 (h, i, j, k, l)
h = 1 (first event, sends to b)
i = 2 (receives from m=1 → max(1,1)+1 = 2)
j = 4 (receives from s=3 → max(2,3)+1 = 4)
k=5
l = 8 (receives from v=7 → max(5,7)+1 = 8)
Process P3 (m, n, o, p, q)
m = 1 (first event, sends to i)
n = 3 (receives from i=2 → max(1,2)+1 = 3)
o = 4 (receives from c=3 → max(3,3)+1 = 4)
p=5
q = 10 (receives from g=9 → max(5,9)+1 = 10)
Process P4 (r, s, t, u, v)
r = 2 (receives from a=1 → max(0,1)+1 = 2)
s=3
t = 5 (receives from d=4 → max(3,4)+1 = 5)
u=6
v=7
Final Answer Table
UNIT 4
Q1 With a neat diagram, explain the three types of replicas and their logical organization.
Replication means creating and storing multiple copies of data/files on different servers in
a distributed system.
These copies are called replicas.
Replication improves:
Availability
Reliability
Performance
Fault tolerance
Simple Definition:
Replication = Storing copies of data at multiple locations
2. Logical Organization of Replicas (Using Given Diagram)
Permanent replicas → Fixed copies stored permanently
Server-initiated replicas → Created by server when needed
Client-initiated replicas → Created by client (cache copy)
A) Permanent Replicas
Permanent replicas are fixed copies of data stored permanently on servers.
These replicas always exist in the system.
Working:
Original data is stored on Primary Server
Permanent copies are stored on Replica Servers
Client request can be served from these servers
Features:
Always available
Long-term storage
Controlled by system administrator
Example:
Google data centers
Banking databases
Advantages:
High availability
Reliability
Fault tolerance
B) Server-Initiated Replicas
These replicas are created by the server automatically when demand increases.
Server decides:
Where to create copy
When to create copy
When to remove copy
Working:
1. Client requests file
2. Server notices high access demand
3. Server creates copy at another server
4. Future requests are served faster
Features:
Controlled by server
Temporary or dynamic
Used for load balancing
Example:
Content Delivery Networks (CDN)
Advantages:
Faster access
Reduced server load
Better performance
C) Client-Initiated Replicas
These replicas are created by the client itself.
Client stores a local copy (cache) after receiving data.
Working:
Client requests data from server
Server sends data
Client stores local copy in cache
Next request uses cached copy
Features:
Local temporary copy
Controlled by client
Improves response time
Example:
Web browser cache
Local file cache
Advantages:
Faster access
Less network traffic
Reduced server load
Key Issues in Replica Management
Replica management deals with maintaining multiple copies (replicas) of data in a
distributed system. The main issues are:
1) Replica Placement
Deciding where replicas should be stored in the network.
Replica servers should be placed close to users for faster access.
Issue: Wrong placement increases delay and cost.
2) Consistency Management
All replicas should contain the same updated data.
If one copy changes, other replicas must also be updated.
Issue: Some replicas may contain old/outdated data.
3) Update Propagation
Changes made to one replica must be sent to all other replicas.
Issue: Delay in sending updates causes inconsistency.
4) Synchronization
Keeping all replicas synchronized with each other.
Issue: Network delays or failures may cause mismatched copies.
5) Fault Tolerance
If one replica/server fails, another replica should continue serving users.
Issue: Need backup and recovery mechanisms.
6) Scalability
Managing replicas efficiently when the system grows.
Issue: More replicas = more complexity in updates and management.
7) Replica Selection
Deciding which replica should serve a client request.
Issue: Choosing a far or overloaded replica reduces performance.
8) Security and Access Control
Protecting replicated data from unauthorized access.
Issue: Multiple copies increase security risks.
Q2 Discuss the two important reasons for wanting to replicate data and how does
replication relate to scalability.
Data replication means storing multiple copies of the same data on different servers or
locations in a distributed system.
These copies are called replicas.
2. Two Important Reasons for Replicating Data
A) Improve Reliability and Availability
One important reason for replication is to make data always available, even if a server fails.
Explanation:
Suppose data is stored on only one server.
If that server crashes:
Data becomes unavailable
System may stop working
But if copies are stored on multiple servers:
Another server can provide data
System continues working
Example:
Bank database stored on multiple servers.
If one server fails, backup server works.
Benefits:
High availability
Fault tolerance
Better reliability
Data backup
B) Improve Performance
Another reason is to increase speed of data access.
Explanation:
If all clients access one server:
Server becomes overloaded
Response becomes slow
If data is replicated:
Clients can use nearest replica
Load is shared
Example:
Video streaming websites store copies in many servers.
Users get data from nearest server.
Benefits:
Faster response
Reduced network traffic
Better load balancing
Improved user experience
3. How Replication Relates to Scalability
Scalability means the ability of a system to handle more users, more requests, and larger
data without performance loss.
Relation Between Replication and Scalability
Replication helps scalability because it distributes workload across many servers.
Explanation:
Without replication:
One server handles all requests
Server gets overloaded
Performance decreases
With replication:
Requests are divided among replicas
Load is shared
System supports more users
Example:
Suppose 10,000 users request same file.
Without replication:
One server handles all requests → slow
With replication:
Many servers share requests → faster
4. Replication Improves Scalability in Three Ways
(i) Load Distribution
Multiple replicas handle requests together.
This reduces burden on one server.
(ii) Better Read Performance
Clients can read data from nearest replica.
More users can access data at same time.
(iii) Geographic Scalability
Copies can be placed in different locations.
Users worldwide get faster access.
5. Limitation of Replication in Scalability
Replication improves read scalability, but updates become difficult.
Problem:
If data changes:
All replicas must be updated
Synchronization becomes complex
This is called consistency problem.
# How Are Replicas Kept Consistent?
Consistency means:
All copies shoul the same updated data
Problem:
Suppose original data changes.
If replicas are not updated:
One server shows old data
Another shows new data
This causes inconsistency.
Replicas are kept consistent by:
1. Update Propagation – Changes made in one replica are sent to all other replicas.
2. Synchronous Replication – All replicas are updated at the same time.
3. Asynchronous Replication – Updates are sent later after the main server is updated.
4. Synchronization Protocols – Special protocols ensure all copies match.
Main issue: Preventing outdated or conflicting copies.
Q3 Describe the following independent axes for defining inconsistencies with examples
(numerical deviation, staleness, ordering).
In a distributed system, data is often stored in multiple replicas (copies). When one copy is
updated, other copies may not update immediately. As a result, inconsistency occurs.
Inconsistency = Different replicas showing different values or states
To measure inconsistency, three independent axes are used:
1. Numerical Deviation
2. Staleness
3. Ordering
2. Numerical Deviation
Numerical deviation means:
Difference in data values between replicas
It measures how much the replica value differs from the latest correct value.
Example:
Suppose bank account balance:
Original server = ₹10,000
Replica server = ₹9,500
Difference:
₹10,000 – ₹9,500 = ₹500
So numerical deviation = ₹500
Importance:
Used when exact value matters in:
Banking
Stock market
Inventory systems
3. Staleness
Staleness means:
How old or outdated a replica is compared to the latest data
It measures the time delay in update.
Simple Definition:
Staleness = Time difference between latest data and replica data
Example:
Suppose latest weather data updated at:
10:00 AM
Replica still shows data from:
9:55 AM
Difference:
5 minutes
So staleness = 5 minutes
Importance:
Important in:
Real-time systems
Online trading
News updates
Memory Tip:
Staleness = “How old is the data?”
4. Ordering
Ordering means:
Updates must be seen in the correct sequence by all replicas
If updates arrive in wrong order, inconsistency occurs.
Simple Definition:
Ordering = Sequence of updates should remain correct
Example:
Suppose two updates:
1. Balance = ₹1000
2. Withdraw ₹200 → Balance = ₹800
Correct order:
₹1000 → ₹800
If replica gets updates in wrong order:
First ₹800, then ₹1000
Replica shows incorrect result.
This is ordering inconsistency.
Importance:
Important in:
Banking transactions
Messaging systems
Distributed databases
Q4 What is the key issue in distributed system that supports replication? Differentiate
replica-server and content placement. Discuss ways to compute best placement of replica
servers.
1. Key Issue in Distributed Systems Supporting Replication
In distributed systems, replication means storing multiple copies of data on different
servers.
This improves:
Performance
Availability
Reliability
But the main problem is:
Replica Management (Consistency and Placement)
Key Issue:
Keeping replicas consistent while deciding where replicas should be placed.
Explanation:
Suppose one copy of data is updated.
Then:
All replicas must also be updated
Otherwise some servers show old data
Also:
Replicas should be placed in correct locations for better performance
So the key issues are:
1. Consistency management
2. Replica placement
Example:
Bank balance:
Main server = ₹10,000
Replica server = ₹9,000
This causes inconsistency.
2. Replica-Server Placement vs Content Placement
These are two different placement decisions in replication.
A) Replica-Server Placement
Replica-server placement means:
Deciding where to place the replica servers in the network
Focus:
Choosing:
Which machines
Which locations
Which servers
should store replicas.
Example:
Company may place servers in:
Mumbai
Delhi
Pune
to serve users faster.
Goal:
Reduce:
Network delay
Server load
Access time
B) Content Placement
Content placement means:
Deciding what data should be stored on which replica server
Focus:
Choosing:
Which file
Which webpage
Which video
should be stored on a specific replica server.
Example:
Popular movie stored in Pune server because many Pune users request it.
Goal:
Store the right content at right location.
3. Difference Between Replica-Server Placement and Content Placement
Decides where replica servers should be Decides what data/content should be stored
placed in the network on replica servers
Helps reduce network delay and server load Helps improve data access speed
Example: Placing servers in Mumbai, Pune, Example: Storing popular video on Pune
Delhi server
Primary-Backup Protocol
Primary-backup protocol is a replication protocol in which one server acts as the Primary
Server (active) and another acts as the Backup Server (standby). The primary handles client
requests, while the backup keeps an updated copy of data.
Explanation using the given diagram
1. Client sends request to Primary Server
o As shown in the diagram (1. Request), the client sends its request to the
Primary Server (Active).
2. Primary forwards request to Backup Server
o The primary processes the request and sends the update to the Backup
Server (Standby) (2. Forward Request).
3. Backup sends acknowledgment (ACK)
o The backup updates its copy and sends an ACK back to the primary (2. Ack).
4. Primary replies to Client
o After receiving ACK from the backup, the primary sends the final response to
the client (3. Reply).
Diagram:
Failure Handling
If the Primary Server fails, the Backup Server takes over and becomes the new
primary.
This ensures fault tolerance and high availability.
Q12 Discuss and compare “Push versus Pull Protocols” propagation design issue for
content distribution.
In distributed systems, when data is updated on one server, the changes must be
propagated (sent) to replicas.
There are two main propagation protocols:
1. Push Protocol
2. Pull Protocol
These are used in content distribution to keep replicas updated.
2. Push Protocol
In a Push Protocol, the server automatically sends updated data to replicas whenever data
changes.
Working:
Step 1:
Original server updates data.
Step 2:
Server immediately sends update to replicas.
Step 3:
Replicas update their copy.
Example:
News server updates breaking news and sends it immediately to all replica servers.
Advantages:
Fast update propagation
Better consistency
Clients get latest data quickly
Disadvantages:
More communication overhead
Unnecessary updates may be sent
3. Pull Protocol
In a Pull Protocol, replicas request updates from the server when needed.
Server does not send updates automatically.
Working:
Step 1:
Server data changes.
Step 2:
Replica checks server after some time.
Step 3:
Replica requests updated data.
Example:
Web browser checks server for latest webpage version.
Advantages:
Less communication overhead
Efficient when updates are rare
Disadvantages:
Updates may be delayed
Replica may temporarily show old data
4. Comparison Between Push and Pull Protocols
Server automatically sends updates to replicas Replica requests updates from server
Suitable when updates are frequent Suitable when updates are rare
Replicas receive updates immediately Replicas get updates only when they ask
May send unnecessary updates even if not needed Updates are sent only when required
Used in stock market, news alerts Used in web browsers, cache systems
UNIT 5
Q1 Describe the architecture of Sun Network File System in detail.
Sun Network File System (NFS) is a distributed file system developed by Sun Microsystems.
It allows users to access files stored on a remote server as if they were local files.
2. Architecture of Sun NFS (Using Given Diagram)
The given diagram shows that NFS follows a client-server architecture.
It has two sides:
Client Side
Server Side
Communication takes place using RPC/XDR messages.
3. Explanation of Given Diagram
A) Client Side
(i) System Call Interface
This is the interface through which user programs request file operations such as:
Open
Read
Write
(ii) Virtual File System (VFS)
VFS provides a common interface for:
Local file access
Remote file access
Function:
Checks whether file is local or remote
Hides file location from user
(iii) Local File System
If file is local:
VFS sends request to local file system
File is accessed from local disk
(iv) NFS Client
If file is remote:
VFS sends request to NFS client
Function:
Converts file request into NFS request
Sends message to server using RPC/XDR
(v) Local Disk
Stores local files of client machine.
B) Communication (RPC / XDR)
Client and server communicate through:
RPC (Remote Procedure Call)
Used to send file operation requests.
XDR (External Data Representation)
Used to convert data into standard format.
Function:
Sends request from client to server
Returns response from server to client
C) Server Side
(i) NFS Server
Receives request from NFS client.
(ii) Virtual File System (VFS)
Provides interface between:
NFS server
Local file system
(iii) Local File System
Accesses actual files stored on server disk.
(iv) Local Disk
Stores remote shared files.
4. Working of Sun NFS
Step 1:
User requests file through System Call Interface
Step 2:
VFS checks:
Local file? → Local file system
Remote file? → NFS client
Step 3:
NFS client sends request to server using RPC/XDR
Step 4:
NFS server receives request
Step 5:
Server accesses file from local disk
Step 6:
Response sent back to client
Step 7:
User accesses file as if it were local
Q2 Discuss the master-slave architecture of Hadoop Distributed File System along with
functions of its key components.
HDFS (Hadoop Distributed File System) is a distributed file system used to store very large
files across multiple machines in a Hadoop cluster.
It follows a Master-Slave Architecture.
Simple Definition:
HDFS = Distributed file storage system for big data
2. Master-Slave Architecture of HDFS
In HDFS:
One node acts as Master (NameNode)
Many nodes act as Slaves (DataNodes)
The client communicates with both for storing and retrieving data.
3. Explanation of Given Diagram
The diagram shows:
(i) Client
Sends request to NameNode
Reads/Writes data to DataNodes
(ii) NameNode (Master)
Stores metadata
Controls DataNodes
(iii) DataNodes (Slaves)
Store actual data blocks
4. Key Components of HDFS
A) NameNode (Master)
NameNode is the main server of HDFS.
It manages the file system.
Functions:
Stores metadata (file names, directory structure)
Keeps record of which block is stored in which DataNode
Handles client requests
Controls replication
Monitors DataNodes using heartbeat
Example from diagram:
NameNode keeps record like:
file1 → Block1, Block2, Block3
file2 → Block1, Block4
B) DataNode (Slave)
DataNodes are worker nodes.
They store actual file data.
Functions:
Store file blocks
Read/write data
Send heartbeat to NameNode
Send block reports
Example from diagram:
DataNode 1 stores Block 1, 2, 4
DataNode 2 stores Block 1, 3, 5
DataNode 3 stores Block 2, 3, 4
Simple Memory Tip:
DataNode = Stores actual data
C) Client
Client is the user or application that accesses HDFS.
Functions:
Sends metadata request to NameNode
Reads/Writes data to DataNodes
Working:
Client first asks NameNode for file location, then directly accesses DataNodes.
5. Working of HDFS (Using Diagram)
Step 1:
Client sends metadata request to NameNode.
Step 2:
NameNode replies with block location.
Step 3:
Client directly reads/writes data from DataNodes.
Step 4:
DataNodes send:
Heartbeat
Block report
to NameNode.
Step 5:
Data blocks are replicated across DataNodes.
(Shown in diagram)
Q3 What are the key design issues for distributed file systems? Describe the requirements
for distributed file systems.
A Distributed File System (DFS) is a file system in which files are stored on multiple
computers but appear to users as a single file system.
2. Key Design Issues of Distributed File Systems
While designing a DFS, some important issues must be considered.
A) Naming and Transparency
Users should access files in the same way whether files are:
Local
Remote
Goal:
Hide file location from user.
B) File Sharing and Concurrency
Many users may access the same file at the same time.
Issue:
System must control:
Multiple reads
Multiple writes
to avoid conflicts.
C) Caching
Frequently used files are stored temporarily in cache.
Goal:
Faster access
Reduced network traffic
D) Replication
Multiple copies of files may be stored on different servers.
Goal:
Better availability
Fault tolerance
Faster access
E) Consistency
If one copy of file changes, all replicas must be updated.
Goal:
All users should see correct data.
F) Fault Tolerance
System should continue working even if:
Server fails
Network fails
G) Security
Files should be protected from unauthorized access.
Security includes:
Authentication
Access control
Data protection
H) Scalability
System should support:
More users
More files
More servers
without performance loss.
3. Requirements of Distributed File Systems
A good DFS should satisfy the following requirements:
A) Transparency
Remote files should appear like local files.
B) Reliability
System should work correctly even if faults occur.
C) Availability
Files should be available whenever users request them.
D) Performance
File access should be fast.
E) Scalability
System should grow easily with increasing users and data.
F) Security
Only authorized users should access files.
G) Consistency
All users should see updated and correct file data.
H) Fault Recovery
System should recover from failures automatically.
Q4 What is a Directory Service? What is the difference between DNS and X.500? Describe
in detail the components of X.500 service architecture.
DNS X.500
Working:
Step 1:
Client sends request to Cache 1
Step 2:
If data not found in Cache 1,
Cache 1 checks:
Cache 2
Cache 3
Step 3:
If found, data is sent to client
Else:
Origin server is contacted
5. Advantages of Cooperative Caching
Reduces server load
Faster response
Better bandwidth usage
Improves cache hit rate
UNIT 6
Q1 Explain the following in brief: Wearable devices, PVM, JINI.#3
Wearable devices are small smart electronic devices that can be worn on the body and
connected to a computer or network.
They collect information, process data, and provide services while the user is moving.
Examples
Smart watch
Fitness band
Smart glasses
Heart monitoring device
Smart shoes
Features of Wearable Devices
A) Portable
Small and light, easy to wear.
B) Wireless Communication
Uses:
Bluetooth
Wi-Fi
Internet
to send data.
C) Sensors
Collect information such as:
Heart rate
Steps
Temperature
Location
D) Real-Time Monitoring
Provides instant data to user.
Uses of Wearable Devices
Health monitoring
Fitness tracking
Navigation
Communication
Medical applications
Example
A smart watch can:
Count steps
Measure heart rate
Show messages
Advantages
Easy to use
Portable
Disadvantages
Battery limitations
Security/privacy issues
2. PVM (Parallel Virtual Machine)
PVM (Parallel Virtual Machine) is software that connects many computers through a
network and makes them work like one large parallel computer.
It is used for distributed and parallel computing.
Need for PVM
Some tasks need very high processing power.
Instead of one computer:
PVM uses many computers together.
Working of PVM
Step 1: Many computers are connected in a network.
Step 2: A large task is divided into smaller tasks.
Step 3: Each computer works on its part.
Step 4: Results are combined.
Components of PVM
A) Host Machine
Main computer controlling the work.
B) Slave Machines
Other computers helping in processing.
C) Message Passing
Computers communicate by sending messages.
Features of PVM
Parallel processing
Distributed computing
Message passing
Fault tolerance
Example
Weather forecasting:
Large calculations divided among many computers.
Advantages
Faster execution
Better resource utilization
Low cost using existing computers
Disadvantages
Network dependency
Communication overhead
3. JINI
JINI is a Java-based distributed networking technology that allows devices and services to
join a network and automatically discover each other.
Need for JINI
In distributed systems:
Devices should connect and use services automatically without manual configuration.
JINI makes this possible.
Working of JINI
Step 1: A device joins the network.
Step 2: It registers its service.
Step 3: Other devices discover that service.
Step 4: Devices use the service automatically.
Example
Printer joins office network.
Users automatically find and use it.
Main Components of JINI
A) Service Provider
Device that provides service.
Example:
Printer
B) Lookup Service
Directory that stores available services.
C) Client
User/device that searches for service.
Features of JINI
Service discovery
Dynamic networking
Java-based
Automatic service registration
Advantages
Easy service sharing
Automatic device discovery
Flexible distributed computing
Disadvantages
Java dependency
More complex setup
Q2 How wearable devices work in distributed systems? Discuss the problems involved
with wearable computing.#1
Application is divided into small independent Application is built as one big program
services (monolithic system)
Each service does one specific task All tasks are combined in one application
More scalable (add more services easily) Less scalable (difficult to expand)
Q4 Explain in brief, the key features of Prometheus including data model, query language,
or alerting rules.#3
Prometheus is an open-source monitoring and alerting tool used to collect and monitor
system performance data.
It is commonly used in:
Cloud systems
Distributed systems
Servers
Applications
Example:
Prometheus can monitor:
CPU usage
Memory usage
Server health
Network traffic
2. Key Features of Prometheus
Prometheus has many important features.
A) Time-Series Data Model
Prometheus stores data as time-series data.
Example:
10:00 40%
10:05 50%
10:10 60%
Feature:
Prometheus stores measurements over time.
B) Data Model
Prometheus data model stores information as:
Metric Name + Labels + Value + Timestamp
Example:
cpu_usage{server="server1"} = 75
Where:
cpu_usage → metric name
server="server1" → label
75 → value
Time stored automatically
Components of Data Model
(i) Metric Name
Name of measurement.
Example:
cpu_usage
memory_usage
(ii) Labels
Extra information about metric.
Example:
server name
job name
(iii) Value
Actual measured data.
Example:
75%
(iv) Timestamp
Time when data is collected.
C) PromQL (Query Language)
Prometheus uses a special query language called PromQL (Prometheus Query Language).
Uses:
Search data
Filter metrics
Calculate averages
Generate graphs
Example:
cpu_usage
Shows CPU usage.
avg(cpu_usage)
Shows average CPU usage.
Features:
Powerful filtering
Aggregation
Mathematical operations
D) Alerting Rules
Prometheus can generate alerts when a condition becomes true.
Simple Definition:
Alerting Rules = Automatic warning when system problem occurs
Example:
Rule:
If CPU > 90%
Then:
Send alert
Working:
Step 1:
Prometheus checks metrics continuously
Step 2:
Condition matches alert rule
Step 3:
Alert is sent
Example Alerts:
High CPU usage
Server down
Low memory
Network failure
E) Pull-Based Monitoring
Prometheus collects data by pulling metrics from targets.
Working:
Prometheus asks servers for latest metrics.
Advantage:
Easy monitoring
F) Visualization Support
Prometheus data can be shown as:
Graphs
Dashboards
(using Grafana)
3. Advantages of Prometheus
Real-time monitoring
Easy alerting
Powerful query language
Good for cloud/distributed systems
Time-series storage
Strong auto-discovery
Auto-Discovery Limited Limited
support
Built-in graphical
Dashboard Basic (better with Grafana) Basic dashboard
dashboards
Lower compared to
Scalability High scalability Medium to high
Prometheus
Mach CHORUS
Mainly used for distributed and parallel Mainly used for distributed and real-time
systems systems
Uses Copy-on-Write (COW) to avoid copying Uses Page Remapping to avoid copying
data data
More suitable for research and academic More suitable for commercial and
systems embedded systems