Distributed Systems & Consensus (Raft / Paxos) Interview Questions Hindi mein

Distributed Systems & Consensus (Raft / Paxos) कोर्स के 33 सवाल, हर सवाल के सही जवाब और explanation के साथ। जवाब देखने से पहले ख़ुद सोचें।

Mental Model: Nodes, Messages and Failure

1. What makes distributed systems fundamentally harder than a single-machine program?

  1. Programs must be written in a special language
  2. Parts of the system can fail independently while others keep running
  3. Networks are always too slow for databases
  4. Every node must have identical hardware
जवाब देखें

जवाब: Parts of the system can fail independently while others keep running

Partial failure is the core difficulty: some nodes or links fail while others continue, and a node cannot reliably tell a slow peer from a dead one.

पाठ: Why Distribute, and Why It Is Hard

2. Which failure is Raft NOT designed to tolerate?

  1. A node crashing and restarting from disk
  2. Messages being delayed or reordered
  3. A network partition that isolates the leader
  4. A node that sends deliberately conflicting messages to different peers
जवाब देखें

जवाब: A node that sends deliberately conflicting messages to different peers

That is a Byzantine failure. Raft and Paxos assume nodes may fail and messages may be lost, but nodes never lie.

पाठ: Failure Models: Crash, Omission and Byzantine

3. Why is a timeout only a suspicion of failure, not proof?

  1. Because timeouts are always configured too short
  2. Because clocks on different machines are never synchronised
  3. Because in a partially synchronous network a live node can be arbitrarily slow for a while
  4. Because TCP retransmits every lost packet
जवाब देखें

जवाब: Because in a partially synchronous network a live node can be arbitrarily slow for a while

Without known delay bounds, a slow or paused node and a crashed node produce the same silence. The timeout picks a guess.

पाठ: Timing Models and Failure Detection

Time, Clocks and Ordering Events

4. Why is last-writer-wins by wall-clock timestamp risky across replicas?

  1. Timestamps take too much storage
  2. Clock skew can make a later write carry a smaller timestamp, so it is discarded
  3. Wall clocks cannot represent milliseconds
  4. It requires a consensus round for every read
जवाब देखें

जवाब: Clock skew can make a later write carry a smaller timestamp, so it is discarded

If skew exceeds the real gap between two writes, the order by timestamp differs from the real order and the newer value is lost silently.

पाठ: Physical Clocks and Why They Lie

5. If Lamport timestamps satisfy L(a) < L(b), what can you conclude?

  1. a happened before b
  2. a and b are concurrent
  3. b happened before a
  4. b did not happen before a, but a and b may be concurrent
जवाब देखें

जवाब: b did not happen before a, but a and b may be concurrent

Lamport clocks guarantee a -> b implies L(a) < L(b). The reverse inference is invalid, so L(a) < L(b) only rules out b -> a.

पाठ: Lamport Clocks and Happens-Before

6. Vectors {A:2, B:0} and {A:1, B:1} are compared. What is the relationship?

  1. Concurrent
  2. The first happened before the second
  3. The second happened before the first
  4. They are equal
जवाब देखें

जवाब: Concurrent

The first is larger in A, the second is larger in B. Neither dominates, so neither event saw the other: they are concurrent.

पाठ: Vector Clocks and Detecting Concurrency

Replication and Consistency Models

7. With N = 5 replicas, which setting guarantees read and write quorums always overlap?

  1. W = 2, R = 2
  2. W = 1, R = 3
  3. W = 3, R = 3
  4. W = 2, R = 3
जवाब देखें

जवाब: W = 3, R = 3

Overlap needs W + R > N. Only 3 + 3 = 6 exceeds 5; the other combinations total 4 or 5.

पाठ: Replication Strategies and Quorums

8. Client A's write completes. Afterwards client B starts a read. Under linearizability, what must B see?

  1. The value written by A, or a later one
  2. Any value that was ever written
  3. A's value only if A and B talk to the same replica
  4. A's value only after a fixed replication delay
जवाब देखें

जवाब: The value written by A, or a later one

Linearizability respects real time: an operation that starts after another finished must observe its effects.

पाठ: Consistency Models: Linearizable to Eventual

9. Under PACELC, what trade-off does a system face when there is NO partition?

  1. Availability vs partition tolerance
  2. Durability vs throughput
  3. Safety vs liveness
  4. Latency vs consistency
जवाब देखें

जवाब: Latency vs consistency

The 'ELC' part: else (no partition), choose lower latency or stronger consistency.

पाठ: CAP and PACELC Without the Myths

The Consensus Problem

10. Which property rules out an algorithm that always decides the value 0 regardless of what was proposed?

  1. Agreement
  2. Validity
  3. Termination
  4. Linearizability
जवाब देखें

जवाब: Validity

Validity requires the decided value to be one that some node proposed; a constant answer satisfies agreement and termination but not validity.

पाठ: The Consensus Problem and State Machine Replication

11. What does Raft give up in response to FLP?

  1. Agreement during partitions
  2. Validity of decided values
  3. Durability of committed entries
  4. Guaranteed termination under arbitrary timing
जवाब देखें

जवाब: Guaranteed termination under arbitrary timing

Raft is always safe; it only makes progress once timing is well-behaved enough to elect a stable leader.

पाठ: The FLP Impossibility Result

12. Why can a 2PC participant that voted yes not decide on its own after the coordinator crashes?

  1. It does not know whether every other participant voted yes
  2. It has already released its locks
  3. Its vote was not written to disk
  4. 2PC uses majority voting, so it must wait for a quorum
जवाब देखें

जवाब: It does not know whether every other participant voted yes

Another participant may have voted no (so the result is abort) or all may have voted yes and the coordinator decided commit. The prepared participant cannot tell which.

पाठ: Two-Phase Commit vs Consensus

Paxos

13. In phase 2a, a proposer's promises report accepted values (ballot 3, 'A') and (ballot 5, 'B'). What must it propose?

  1. Its own new value
  2. 'A', because it was accepted first
  3. 'B', the value with the highest accepted ballot
  4. Nothing; it must restart phase 1
जवाब देखें

जवाब: 'B', the value with the highest accepted ballot

The rule is to adopt the value with the highest accepted ballot among the promises. This preserves any value that might already be chosen.

पाठ: Basic Paxos: Prepare, Promise, Accept

14. Which property guarantees that a later Paxos proposer discovers an already chosen value?

  1. Every acceptor stores every ballot ever seen
  2. Any two majorities of acceptors share at least one acceptor
  3. Ballot numbers are synchronised to wall-clock time
  4. Learners broadcast the chosen value to all proposers before phase 1
जवाब देखें

जवाब: Any two majorities of acceptors share at least one acceptor

Quorum intersection means the new proposer's majority includes some acceptor that accepted the chosen value, and that acceptor reports it in its promise.

पाठ: Why Paxos Is Safe, and Dueling Proposers

15. What does a stable Multi-Paxos leader skip for each new log entry?

  1. Phase 2 (accept)
  2. Writing entries to disk
  3. Phase 1 (prepare/promise)
  4. Waiting for a majority of acceptors
जवाब देखें

जवाब: Phase 1 (prepare/promise)

Phase 1 is done once for a range of slots, so steady-state commits need only phase 2: one round trip to a majority.

पाठ: Multi-Paxos and the Paxos Family

Raft: Terms and Leader Election

16. A Raft leader in term 5 receives an AppendEntries response carrying term 8. What does it do?

  1. Ignore it, since leaders outrank followers
  2. Send a heartbeat to reassert leadership
  3. Start a new election in term 6
  4. Update its term to 8 and become a follower
जवाब देखें

जवाब: Update its term to 8 and become a follower

Seeing a higher term means its leadership is stale. It adopts the higher term and reverts to follower.

पाठ: Raft Overview: Roles, Terms and RPCs

17. Candidate log ends at (term 4, index 9). Voter log ends at (term 5, index 3). Will the voter grant its vote, assuming it has not voted this term?

  1. No, the voter's last entry has a higher term, so it is more up-to-date
  2. Yes, the candidate's log is longer
  3. Yes, votes are granted to the first candidate regardless of logs
  4. No, the candidate's index is not equal to the voter's
जवाब देखें

जवाब: No, the voter's last entry has a higher term, so it is more up-to-date

Up-to-date is decided by last term first. Term 5 beats term 4, so the voter's log is more up-to-date and it refuses.

पाठ: Leader Election and Randomised Timeouts

Raft: Log Replication and Safety

18. What does a Raft follower do when AppendEntries' prevLogIndex/prevLogTerm do not match its log?

  1. Accepts the entries and fixes the log later
  2. Rejects the request so the leader retries from an earlier index
  3. Starts an election because the leader is faulty
  4. Overwrites the leader's log with its own
जवाब देखें

जवाब: Rejects the request so the leader retries from an earlier index

A mismatch means the logs diverge at or before that index. The follower rejects, and the leader backs nextIndex up until it finds the last matching entry.

पाठ: Log Replication with AppendEntries

19. Why does a new Raft leader often append a no-op entry immediately?

  1. To reset all followers' logs
  2. To measure network latency to followers
  3. To trigger snapshotting
  4. To commit an entry in its own term, which also commits all earlier entries
जवाब देखें

जवाब: To commit an entry in its own term, which also commits all earlier entries

Earlier-term entries cannot be committed by counting replicas. Committing a current-term no-op commits everything before it through Log Matching.

पाठ: Committing Entries and the Current-Term Rule

20. Which rule ensures a newly elected Raft leader already holds every committed entry?

  1. Followers forward their logs to the candidate before voting
  2. Leaders replay the whole log from a snapshot after election
  3. Voters reject candidates whose logs are less up-to-date than their own
  4. Only the server with the lowest ID may become leader
जवाब देखें

जवाब: Voters reject candidates whose logs are less up-to-date than their own

The election restriction combined with majority overlap guarantees the winner's log contains all committed entries.

पाठ: Raft Safety: Election Restriction and Leader Completeness

Raft in Practice: Membership, Snapshots and Reads

21. Why does Raft recommend adding or removing only one server at a time?

  1. Any majority of the old configuration overlaps any majority of the new one, so two leaders cannot be elected
  2. It reduces the size of snapshots
  3. It avoids the need for leader election entirely
  4. It lets followers skip the consistency check
जवाब देखें

जवाब: Any majority of the old configuration overlaps any majority of the new one, so two leaders cannot be elected

With a single-server change, old and new majorities always share a server, which prevents disjoint majorities from electing separate leaders.

पाठ: Cluster Membership Changes

22. When does a Raft leader send InstallSnapshot to a follower?

  1. After every committed entry
  2. When the follower needs entries the leader has already discarded during compaction
  3. Whenever a new leader is elected
  4. When the follower's log is longer than the leader's
जवाब देखें

जवाब: When the follower needs entries the leader has already discarded during compaction

If nextIndex for a follower falls before the leader's snapshot point, the required entries no longer exist, so the leader ships the snapshot instead.

पाठ: Snapshots and Log Compaction

23. What extra assumption makes lease-based reads faster but riskier than ReadIndex?

  1. Disks never lose data
  2. Messages are never reordered
  3. Clock drift between servers is bounded
  4. There are always an odd number of servers
जवाब देखें

जवाब: Clock drift between servers is bounded

Lease reads skip the heartbeat round by trusting that time passes at roughly the same rate on all servers. Large drift or long pauses can break that.

पाठ: Linearizable Reads: Log Reads, ReadIndex and Leases

Consensus in Real Systems: etcd, ZooKeeper and Locks

24. Which etcd feature lets a key disappear automatically when its owner stops responding?

  1. Watches
  2. Revisions
  3. Leases
  4. Compaction
जवाब देखें

जवाब: Leases

Keys attached to a lease are deleted when the lease expires, which happens when the client stops sending keep-alives.

पाठ: etcd: A Raft-Backed Key-Value Store

25. What happens to an ephemeral znode when the client session that created it expires?

  1. It is deleted automatically
  2. It becomes persistent
  3. It is moved to the end of the sequence
  4. It is kept but marked read-only
जवाब देखें

जवाब: It is deleted automatically

Ephemeral znodes live only as long as their session, which is what makes them useful for liveness-based recipes like locks and leader election.

पाठ: ZooKeeper and the Zab Protocol

26. Where must a fencing token be checked to prevent writes from a paused former lock holder?

  1. In the client, before every write
  2. In the lock service, when the lease expires
  3. In the network load balancer
  4. In the storage or resource that receives the write
जवाब देखें

जवाब: In the storage or resource that receives the write

Only the resource sees writes from both clients in the order they arrive, so only it can reject the one with the stale token.

पाठ: Distributed Locks, Leases and Fencing Tokens

Performance, Pitfalls and Verification

27. A 5-node cluster's leader has follower RTTs of 2, 3, 70 and 90 ms. Roughly what replication latency does each commit add?

  1. 90 ms
  2. 2 ms
  3. 3 ms
  4. 70 ms
जवाब देखें

जवाब: 3 ms

The leader plus two followers form a majority of 5. The two fastest followers answer in 2 and 3 ms, so the commit waits about 3 ms.

पाठ: Performance: Latency, Batching and Multi-Raft

28. What problem does Raft's Pre-Vote extension solve?

  1. A rejoining partitioned node with an inflated term forcing an unnecessary election
  2. Slow disks delaying fsync
  3. Logs growing without bound
  4. Clients reading stale data from followers
जवाब देखें

जवाब: A rejoining partitioned node with an inflated term forcing an unnecessary election

Pre-vote lets a node check whether it could win before incrementing its term, so an isolated node cannot disrupt a healthy leader when it reconnects.

पाठ: Production Pitfalls: Split Brain, Pre-Vote and Disruptive Nodes

29. What is the main advantage of deterministic simulation testing over running a real cluster with random faults?

  1. It needs no test assertions
  2. Any failure can be reproduced exactly by replaying the same seed
  3. It proves the protocol correct for all cluster sizes
  4. It measures production latency accurately
जवाब देखें

जवाब: Any failure can be reproduced exactly by replaying the same seed

Because every random choice comes from the seed, a failing run replays identically, which turns rare heisenbugs into debuggable ones.

पाठ: Testing and Verifying Consensus Systems

30. How many replicas does a classic BFT protocol need to tolerate 2 Byzantine nodes?

  1. 5
  2. 6
  3. 4
  4. 7
जवाब देखें

जवाब: 7

Byzantine tolerance needs 3f + 1 replicas: 3 x 2 + 1 = 7. Five would be enough only for crash faults.

पाठ: Byzantine Fault Tolerance and Blockchains

Revision and Interview Prep

31. Which pairing is correct?

  1. Vector clocks: detect concurrent events; Lamport clocks: total order consistent with causality
  2. Lamport clocks: detect concurrent events; vector clocks: wall-clock order
  3. Both give the real-time order of events
  4. Neither respects happens-before
जवाब देखें

जवाब: Vector clocks: detect concurrent events; Lamport clocks: total order consistent with causality

Lamport clocks respect causality and can be made a total order with tie-breaking, but cannot prove concurrency; vector clocks can.

पाठ: Cheat Sheet: Everything on One Page

32. An interviewer asks why a 4-node Raft cluster is rarely used. What is the best answer?

  1. Raft does not support even-sized clusters
  2. Four nodes cannot elect a leader
  3. It tolerates the same single failure as 3 nodes while needing 3 acknowledgements per commit
  4. Four nodes always cause split brain
जवाब देखें

जवाब: It tolerates the same single failure as 3 nodes while needing 3 acknowledgements per commit

A majority of 4 is 3, so only one failure is tolerated, exactly like 3 nodes, while every write waits for more acknowledgements.

पाठ: Common Interview and Exam Questions

33. A Raft cluster of 5 is split 3 | 2 by a partition, and the old leader is on the 2-node side. What happens?

  1. Both sides keep committing writes and merge later
  2. The 3-node side elects a new leader and commits; the old leader cannot commit anything
  3. The whole cluster stops until the partition heals
  4. The 2-node side keeps the leader because leaders never change during partitions
जवाब देखें

जवाब: The 3-node side elects a new leader and commits; the old leader cannot commit anything

Only the side with a majority can elect a leader and commit. The isolated old leader cannot reach a quorum, so its writes never commit, and it steps down when it sees the higher term.

पाठ: Mixed Self-Check

← कोर्स पर वापस जाएँ