0% found this document useful (0 votes)
26 views9 pages

Dssss

The document discusses various concepts related to distributed systems, including consistent and transitless global states, types of deadlocks, vector clocks, and performance metrics for mutual exclusion algorithms. It also covers recovery mechanisms, the two-phase commit protocol, and the challenges of fault tolerance, as well as the architecture of distributed file systems and the Byzantine Agreement Problem. Additionally, it examines concurrency control algorithms, limitations of distributed systems, and the Chandy-Lamport snapshot algorithm.

Uploaded by

Abhishek Sharma
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)
26 views9 pages

Dssss

The document discusses various concepts related to distributed systems, including consistent and transitless global states, types of deadlocks, vector clocks, and performance metrics for mutual exclusion algorithms. It also covers recovery mechanisms, the two-phase commit protocol, and the challenges of fault tolerance, as well as the architecture of distributed file systems and the Byzantine Agreement Problem. Additionally, it examines concurrency control algorithms, limitations of distributed systems, and the Chandy-Lamport snapshot algorithm.

Uploaded by

Abhishek Sharma
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/ 9

Distributed Systems: Short Answer Questions (Hinglish)

1. Explain the concept of consistent global state and transitless global state.

 Consistent Global State:


Distributed system ka aisa snapshot jisme koi inconsistency nahi hoti. Agar ek process ne ek
message send kiya hai, to wo snapshot me ya to sender ke pass hoga ya receiver ke pass.
o Example: Process A ne Process B ko message send kiya, aur snapshot ke time tak B wo
receive kar chuka hai.
 Transitless Global State:
Ye ek aisi state hai jisme communication channels me koi in-transit message nahi hote.
o Example: Agar message kisi process ko deliver hone ke liye channel me hai, to wo
transitless global state nahi hogi.

2. Differentiate between resource deadlock and communication deadlock.

 Resource Deadlock:
Jab processes ek dusre ke resources ka wait karte hain aur ek cyclic dependency ban jata hai.
o Example: P1 ko R1 chahiye, jo P2 ke pass hai. Aur P2 ko R2 chahiye, jo P1 ke pass hai.
 Communication Deadlock:
Jab processes message send/receive ke liye ek dusre ka wait karte hain.
o Example: P1 reply ke liye P2 ka wait kare aur P2 reply ke liye P1 ka wait kare.

3. Show how vector clocks are more suitable than Lamport’s logical clock in distributed systems.

 Lamport clocks event ordering ensure karte hain, lekin causal dependency nahi dikhate.
 Vector Clock Advantage:
1. Vector clocks causal relationships (e.g., "happens-before") dikhate hain.
2. Har process apna vector maintain karta hai aur messages exchange ke through update karta
hai.
o Example: Agar P1 ke event ka impact P2 ke event par hai, to vector clocks dependency
explicitly track karenge.

4. List the performance metrics used for evaluating distributed mutual exclusion algorithms.

1. Message Complexity: Critical section access ke liye required messages ka count.


2. Synchronization Delay: Critical section enter karne se pehle lagne wala time.
3. Throughput: Timeframe me critical section enter karne wali successful requests.
4. Fault Tolerance: Failures ke baad system ka recover hone ka ability.

5. Discuss forward and backward recovery mechanisms in distributed systems.

 Forward Recovery:
System fault ke baad new state se recover karta hai.
o Example: Data ko dynamically adjust karke computation resume karna.
 Backward Recovery:
Fault ke baad system previous stable state (checkpoint) par wapas chala jata hai.
o Example: Crash hone ke baad last checkpoint load karke system restart karna.
6. Rank the basic, multi-version, and conservative timestamp ordering algorithms in increasing order
of transaction abort rates.

1. Basic Timestamp Ordering Algorithm (Most Aborts): Direct conflicts me transactions abort hoti
hain.
2. Multi-Version Timestamp Ordering Algorithm: Conflict hone par old versions maintain kar leta
hai, isliye kam aborts hoti hain.
3. Conservative Timestamp Ordering Algorithm (Least Aborts): Conflicts avoid karne ke liye
transactions ko delay karta hai, abort ka chance sabse kam hota hai.

7. Differentiate between flat transactions and nested transactions in distributed systems.

 Flat Transactions: Single-level transactions. Agar ek fail ho jaye, to poori transaction fail hoti hai.
o Example: Bank transaction fail hone par pura rollback hota hai.
 Nested Transactions: Ek parent transaction ke andar sub-transactions hoti hain. Agar ek sub-
transaction fail kare, to parent transaction decide karti hai ki rollback hona chahiye ya nahi.

8. Explain the need for fault-tolerance in distributed systems and the concept of transparent failure
handling.

 Need for Fault-Tolerance: Distributed systems me failures (node crashes, network errors) avoid
nahi kiya ja sakta, isliye system ko fault-tolerant hona zaroori hai.
 Transparent Failure Handling:
User ko failures ke effects ka pata nahi chalna chahiye.
o Example: Replica systems me agar ek server fail ho jaye, to dusra server automatically use
handle kare.

9. Briefly discuss the two-phase commit protocol for distributed transactions.

 Two-Phase Commit (2PC): Atomic transactions ensure karne ka protocol.


1. Phase 1 - Prepare: Coordinator saare participants se poochta hai ki transaction execute karne
ke liye ready hain ya nahi.
2. Phase 2 - Commit/Abort: Agar sab ready ho to commit hoti hai, otherwise abort ho jata hai.

10. What is the domino effect in distributed recovery systems? How can it be avoided?

 Domino Effect:
Jab ek process failure ke baad recover hone ke liye apne dependent processes ko rollback karna padta
hai, aur ye rollback ek chain reaction ban jata hai.
o Example: Multiple checkpoints par dependency ho aur ek checkpoint fail ho jaye, to poore
system ko rollback karna padta hai.
 Avoidance:
1. Consistent checkpoints lena.
2. Message logging: Saari states ko log karke recovery ke liye use karna.

SECTION B: Long Answer Questions (Hinglish)

1. Classify Deadlock Detection Algorithms and Describe Path-Pushing Deadlock Detection Algorithm

 Classification of Deadlock Detection Algorithms:


1. Centralized Algorithms:
 Ek central coordinator sabhi processes ki dependencies ko track karta hai aur deadlock
detect karta hai.
 Advantage: Simple implementation.
 Disadvantage: Single point of failure.
2. Distributed Algorithms:
 Sabhi processes apni dependencies ko share karte hain aur deadlock detection
collaboratively hota hai.
 Advantage: No single point of failure.
 Disadvantage: Zyada message passing overhead.
3. Hierarchical Algorithms:
 Processes ko hierarchy me organize karke coordinators ka workload divide kiya jata hai.
 Advantage: Balance hota hai.
 Disadvantage: Implementation complex hoti hai.
 Path-Pushing Deadlock Detection Algorithm:
o Ye distributed deadlock detection ke liye use hota hai, jo Resource Allocation Graph (RAG) ke paths
ko propagate karta hai.

Steps:

2. Ek process (P1) apne dependencies ko ek path ki form me propagate karta hai agar wo kisi resource
ke liye wait kar raha hai.
3. Jis process ko path receive hota hai (e.g., P2), wo apne dependencies ke saath updated path ko aage
forward karta hai.
4. Agar koi process apne hi node ka cyclic path detect kare, to deadlock confirm hota hai.

Example:

o P1 -> R1 -> P2 -> R2 -> P1 (Cycle detected: Deadlock).

2. Explain the Architecture of a Distributed File System (DFS) with Example

What is DFS?
Distributed File System (DFS) ek system hai jisme data multiple nodes ya servers me distributed hota hai, jo
ek large-scale environment me file sharing aur data storage ko optimize karta hai.

Key Components:

1. Clients:
o File access aur modification requests bhejte hain.
2. Metadata Server (Master):
o File location aur metadata (e.g., permissions) manage karta hai.
o Example: Google File System (GFS) me Master Node.
3. Storage Nodes (Slaves):
o Files ko distributed chunks me store karte hain.
o Example: Hadoop Distributed File System (HDFS) me DataNodes.

Characteristics of DFS:

 Scalability: Bade systems me efficiently scale karta hai.


 Fault Tolerance: Multiple replicas create karke failure se recover kar sakta hai.
 Transparency: User ko pata nahi hota ki data physically kaha store ho raha hai.

Example (Hadoop DFS):

 NameNode: Metadata aur block locations ko manage karta hai.


 DataNodes: Data blocks ko physically store karte hain aur failure recovery ke liye replicate karte hain.
3. Compare Dynamic Voting Protocols with Static Voting Protocols and Explain Dynamic Quorum
Adjustment

Comparison Table:

Aspect Dynamic Voting Protocols Static Voting Protocols

Quorum Adjustment Dynamically adjust hote hain Fixed hain

Fault Tolerance High fault-tolerance Low fault-tolerance

Performance Adaptive Consistent but inflexible

Dynamic Voting Protocols:

1. Dynamic quorum adjust hota hai jo nodes ki availability aur failures ke basis par hota hai.
2. Partitioned network me consistency aur reliability ensure karta hai.

Static Voting Protocols:

1. Quorum size fixed hota hai, jo failure aur partition hone par badal nahi sakta.
2. System fail hone ke chances zyada hote hain.

How Dynamic Quorum Adjustment Works:

1. Sabhi nodes vote karte hain.


2. Available nodes ke basis par quorum ka size dynamically adjust hota hai.
3. Read aur write operations dynamically decide kiye jate hain taaki consistency aur fault-tolerance maintained
rahe.

4. Discuss Lock-Based Concurrency Control Algorithms with Examples

What is Concurrency Control?


Concurrency control algorithms ensure karte hain ki multiple transactions ek hi data ko simultaneously
access karte waqt data consistency maintained rahe.

Types of Locks:

1. Shared Locks:
o Multiple transactions ko read operation karne ki permission milti hai.
o Example: Two processes P1 and P2 can read the same data at the same time.
2. Exclusive Locks:
o Sirf ek transaction ko data modify karne ki permission milti hai.
o Example: P1 modifies a record, so P2 cannot read or modify it until P1 releases the lock.
3. Two-Phase Locking Protocol (2PL):
o Locks do phases me handle kiye jate hain:
 Growing Phase: Locks acquire hote hain.
 Shrinking Phase: Locks release hote hain.
o Advantage: Serializability ensure karta hai.
o Disadvantage: Deadlocks ho sakte hain.

5. Describe the Limitations of Distributed Systems and Their Impact on Design

Limitations:
1. Latency Issues:
o Processes ke beech communication me time lagta hai.
o Impact: Low-latency networks design karne padte hain.
2. Fault Handling Complexity:
o Multiple nodes me fault detect karna aur recover karna challenging hota hai.
o Impact: Fault-tolerance mechanisms (replication, checkpointing) design karne ki zarurat hoti hai.
3. Consistency Challenges:
o Distributed environment me consistent data maintain karna difficult hota hai.
o Impact: Strong consistency protocols (e.g., quorum, Paxos) use karne padte hain.
4. Security Risks:
o Distributed systems network-based hote hain, isliye attacks ke chances zyada hote hain.
o Impact: Strong encryption aur authentication techniques lagani padti hain.

Resource Management:

1. Byzantine Agreement Problem

Byzantine Agreement Problem:


Distributed systems me agreement protocol tabhi successful hota hai jab saare non-faulty nodes ek common
value par agree karte hain, even if kuch nodes faulty ho.

Conditions for Agreement:

1. Sabhi non-faulty nodes ko ek common value par agree karna chahiye.


2. Faulty nodes ki incorrect information ka impact na ho.

Why Agreement Cannot Be Reached if More Than 1/3 Nodes Are Faulty:

 Total nodes = nnn


 Faulty nodes = fff
 Byzantine agreement protocol ke liye: n>3fn > 3fn>3f hona chahiye.

Proof:

1. Agar fff faulty nodes hain, to non-faulty nodes apne messages ke basis par majority decide karenge.
2. Agar faulty nodes f>n/3f > n/3f>n/3 ho jayein, to majority consensus impossible ho jata hai kyunki faulty
nodes genuine nodes ko confuse kar deti hain.

Example:

 4 processes (P1, P2, P3, P4).


 2 nodes (P3, P4) faulty hain.
 P1 aur P2 ko conflicting messages milenge, aur wo consensus nahi kar paayenge.

2. Design Issues in Distributed Shared Memory (DSM)

Distributed Shared Memory (DSM):


DSM ek abstraction hai jo distributed systems me memory ko ek single shared memory jaisa dikhata hai,
chahe wo physically distributed ho.

Design Issues in DSM:

1. Consistency Models:
o Different nodes me data consistency ensure karna mushkil hota hai.
o Models: Sequential consistency, causal consistency, eventual consistency.
2. Replication:
o Memory ka replication karte hain taaki faster access mile, lekin replicas ko sync karna challenging
hai.
3. Communication Overhead:
o Data synchronization ke liye frequent communication lagta hai.
4. Fault Tolerance:
o DSM me faults handle karna mushkil hota hai, kyunki ek memory failure poore system ko impact kar
sakta hai.

Algorithms to Implement Consistency:

1. Write-Invalidate Protocol:
o Write hone par purane replicas invalidate hote hain.
o Example: Cache coherence protocols.
2. Write-Update Protocol:
o Write hone par updated data sab replicas me broadcast hota hai.

3. Mutual Exclusion Requirements in Distributed Systems and Its Complexity

Mutual Exclusion Requirements:

1. Mutual Exclusion:
o Sirf ek process ek samay par critical section (CS) me enter kar sakta hai.
2. Fairness:
o Processes ki CS requests ko timestamp ke basis par process karna chahiye.
3. Progress:
o Koi bhi process indefinite time tak wait na kare (no starvation).
4. Fault Tolerance:
o Agar kisi process ya communication ka failure ho jaye, to system mutual exclusion ko impact nahi
hone dega.

Why Mutual Exclusion Is More Complex in Distributed Systems:

 Message Passing: Distributed systems me mutual exclusion ensure karne ke liye message exchange ki
zarurat hoti hai, jo latency aur failures ki wajah se complex ho jata hai.
 Lack of Shared Memory: Processes distributed hone ki wajah se shared memory ka use nahi kar sakte.
 Fault Handling: Failures ka impact har process par ho sakta hai.

Example Algorithm:

 Ricart-Agrawala Algorithm: Messages ka timestamp-based exchange critical section access ensure karta hai.

4. Issues in Building Fault-Tolerant Systems and Types of Faults

Key Issues in Building Fault-Tolerant Systems:

1. Fault Detection:
o System me faults timely detect karna zaruri hai.
2. Redundancy:
o Backup components design karne padte hain taaki system operational rahe.
3. Recovery Mechanisms:
o Consistent checkpoints aur logs fault recovery me help karte hain.
4. Complexity of Distributed Failures:
o Distributed systems me ek fault ka impact multiple nodes par ho sakta hai.

Types of Faults:

1. Transient Faults: Temporary faults jo self-recover ho jati hain.


o Example: Network packet loss.
2. Intermittent Faults: Faults jo kabhi-kabhi occur hoti hain aur unpredictable hoti hain.
o Example: Hardware overheating.
3. Permanent Faults: Faults jo system ko permanently damage kar deti hain aur repair required hota
hai.
o Example: Disk failure.

5. Chandy-Lamport Snapshot Algorithm

Purpose:
Chandy-Lamport Algorithm distributed systems me ek consistent global snapshot lene ke liye use hota hai.
Snapshot system ke processes aur communication channels ke current state ko represent karta hai.

Working of the Algorithm:

1. Initiation:
o Snapshot start karne wala process apni state ko record karta hai aur marker messages bhejta hai
apne outgoing channels pe.
2. Marker Reception Rules:
o Jab ek process first marker receive karta hai, to:
1. Apni current local state record karta hai.
2. Apne outgoing channels pe marker message send karta hai.
o Marker ke baad aane wale messages channel state me record hote hain.
3. Channel State Recording:
o Jab koi message marker se pehle receive hota hai, to wo snapshot me include nahi hota. Marker ke
baad messages channel state me record hote hain.
4. Snapshot Completion:
o Jab har process apna local state aur incoming channel states record kar leta hai, to snapshot
complete hota hai.

Why It Ensures Consistent Snapshot:

 Process states aur channel states ko aise record kiya jata hai ki ek consistent global state mile jo ongoing
computations se unaffected ho.

o Different systems ke resources ko efficiently allocate karna mushkil hota hai.


o Impact: Load balancers aur resource schedulers design karne ki zarurat hoti hai.

SECTION D: Application and Problem-Solving (Hinglish)

1. Solve a Leader Election Problem Using the Bully Algorithm

Scenario:
6 Processes: P1, P2, P3, P4, P5, P6
Process IDs: {12, 9, 4, 6, 15, 10}
Highest ID: 15 (P5 will become the leader).

Step-by-Step Execution:

1. Failure Detection:
o Let’s assume the current leader (P5 with ID = 15) crashes.
o Remaining processes detect the failure and initiate the election.
2. Election Initiation (P1 starts):
o P1 (ID = 12) sends an Election Message to higher ID processes: P5 (15), P6 (10).
3. Responses:
o P5 has crashed, so it won’t respond.
o P6 (ID = 10) replies but can’t become leader as its ID is lower than P1.
4. P2 and P3 Participate:
o Similarly, P2 (ID = 9) and P3 (ID = 4) start election messages, but they both get overridden by P1.
5. P5 Recovers:
o After recovering, P5 with the highest ID (15) overrides the current election and sends Coordinator
Messages to all processes.

Final Outcome:
P5 is declared the new leader as it has the highest ID among the processes.

2. Implement a Fault-Tolerant Transaction System Using Checkpointing

Using Checkpointing in Transactions:

1. Initial Setup:
o Processes periodically save their states as checkpoints during the transaction.
o Communication between processes occurs via message passing.
2. Scenario Example:
o P1, P2, P3 are performing a distributed transaction.
o A checkpoint is created after every step.

Execution:

o Step 1: P1 performs operation and sends message to P2.


o Step 2: P2 completes operation and sends result to P3.
o Step 3: P3 acknowledges success, and the transaction commits.
3. Domino Effect Example:
o If one process crashes (e.g., P3), it rolls back to its last checkpoint.
o Other processes dependent on P3 (e.g., P1 or P2) are also forced to roll back.
o This creates a chain reaction called the domino effect.

How to Avoid Domino Effect:

1. Consistent Checkpoints: All processes must synchronize checkpoints to create a global consistent snapshot.
2. Message Logging: Log messages so that states can be recreated without rollback.
3. Chandy-Lamport Snapshot Algorithm: Use snapshotting to avoid incomplete states.

3. Two-Phase Commit (2PC) Protocol and Three-Phase Commit (3PC)

Two-Phase Commit (2PC):


2PC ensures atomicity in distributed transactions: either all participants commit or all abort.

Phases:

1. Prepare Phase:
o Coordinator: Sends prepare message to all participants asking if they are ready to commit.
o Participants: Reply with “YES” if they are ready or “NO” if they can’t commit.
2. Commit/Abort Phase:
o If all participants reply “YES,” the coordinator sends a Commit Message and the transaction is
committed.
o If any participant replies “NO,” the coordinator sends an Abort Message and the transaction is
aborted.

Example:

 P1 (Coordinator) coordinates with P2 and P3:


o Prepare phase:
 P2 replies YES.
 P3 replies YES.
o Commit phase:
 P1 sends Commit Message to P2 and P3.
o Transaction is committed successfully.

Limitations of 2PC:

1. Blocking Problem: If the coordinator crashes after sending prepare messages, participants cannot make
progress.
2. No Recovery Mechanism: Recovery depends entirely on the coordinator.

Three-Phase Commit (3PC):


3PC adds an extra step to reduce blocking and improve recovery.

Phases:

1. Prepare Phase: Same as 2PC. Coordinator asks participants to prepare.


2. Pre-Commit Phase: Coordinator ensures all participants are ready and sends a pre-commit signal. This
ensures everyone knows the commit is almost finalized.
3. Commit Phase: After pre-commit confirmation, the coordinator sends the final commit message.

Advantages Over 2PC:

1. Non-Blocking: Participants can act independently if the coordinator crashes.


2. Higher Fault-Tolerance: Better state management ensures fewer rollbacks.

Comparison Example:

 If the coordinator crashes after pre-commit in 3PC, participants can use the pre-commit signal to finalize or
abort the transaction.

You might also like