Distributed Systems Notes Tanenbaum
Distributed Systems Notes Tanenbaum
Code Segment The set of instructions that make up the Binary executable
program being executed
Resource Segment References to external resources (files, File handles, TCP sockets,
printers, devices, other processes) printer references
Execution Segment Current execution state: private data, stack, Stack frames, PC register,
program counter local variables
By Identifier Process requires exactly that specific URL, FTP server IP address,
resource — nothing else will do TCP port number
By Type Process only needs any resource of the A monitor, printer, or any local
specified type; exact instance is irrelevant device
1.4 Resource-to-Machine Bindings (3 Types)
These describe how movable a resource is from its current machine:
Binding Type Description Example
Unattached Easily moved between different machines Data files associated only with
without significant cost the migrating process
Fastened Moving is possible but only at relatively high Local databases, complete
cost Web sites
Performance
Access time for remote files should approach local file access times. GFS achieves this by directing
clients straight to chunk servers after one metadata lookup.
Scalability
Should scale to thousands of nodes. Google File System (described in Tanenbaum Chapter 11)
handles this by separating metadata management (single master) from actual data serving (many
chunk servers).
Fault Tolerance
Failures should be handled gracefully. GFS replicates each 64 MB chunk across multiple chunk servers
using a primary-backup scheme.
Consistency
Clients should see consistent data. NFS v2/v3 used stateless servers for simplicity; NFS v4 switched to
stateful servers for better cache consistency over wide-area networks.
Global scheduling raises several fundamental problems. Tanenbaum identifies these issues in the
context of load-sharing and load-balancing systems:
Issue Explanation
Selection Policy Which process to migrate? Newly created processes are preferred over
running ones — they are easier to move (no execution state to transfer) and
disrupt nothing.
Location Policy Which target machine to migrate to? Options: random probing, polling a set
of machines, or using a central directory service. Each trades accuracy for
overhead.
Information Policy When to gather load information? Options: (1) demand-driven — query
when a migration decision is needed; (2) periodic — broadcast at fixed
intervals; (3) state-change — broadcast when load crosses a threshold.
Stability If too many machines simultaneously try to offload work, they may all send
processes to the same idle machines and cause those to become
overloaded. The algorithm then oscillates — a well-known hazard.
Communication Gathering load info and broadcasting decisions consumes network and
Overhead CPU. If too frequent, the overhead can outweigh any performance
improvement from migration.
Heterogeneity Different machines have different speeds and capabilities. A process that
runs fast on Machine A may be slow on Machine B. Comparing loads
across heterogeneous machines is non-trivial.
Migration Cost Moving a running process is expensive — code, execution state, and
resource bindings must all transfer. The benefit of migration must outweigh
this cost. For this reason, newly-arriving processes are preferred migration
candidates.
4. Singhal's Heuristic & Raynal's Tree-Based Algorithm
How It Works
• Each process maintains a local estimate of every other process's state: whether it is currently in
the CS, requesting the CS, or in its remainder section.
• When a process wants to enter the CS, it sends REQUEST only to processes it believes might
be competing — not to all processes.
• When processes exchange messages (REQUESTs, REPLYs), they piggyback state information
to update each other's knowledge about the system.
• Over time, each process's knowledge of others improves, reducing unnecessary messages.
• Worst-case message complexity remains O(N), but in practice (with good heuristics) it is
significantly less.
Why 'Heuristic'?
It uses learned/historical information about process states rather than a deterministic rule.
The algorithm makes educated guesses about who is competing, reducing message count on average.
This is called a heuristic because correctness (safety + liveness) is maintained, but optimality is
approximated.
Key Features
• Processes are arranged in a static logical tree structure. No single coordinator — responsibility
is distributed across the tree.
• A token circulates in the tree. The holder of the token is allowed to enter the critical section.
• A process wanting to enter the CS sends a REQUEST message up toward the root of the tree.
• The token travels back down toward the requesting node, passing through intermediate nodes.
• Requests are queued at each intermediate node in FIFO order, ensuring fairness — starvation
is prevented.
• In a balanced tree, message complexity is O(log N), making it more efficient than Ricart-
Agrawala for large systems.
Algorithm Message Complexity Key Property
Token Ring (Ch. 6.3.5) 1 to N messages per CS entry Token circulates ring; wasteful
when no contention
5. Data-Centric vs. Client-Centric Consistency Models
5.1 Distinction
Aspect Data-Centric Client-Centric
Goal All processes see the same globally A single client never sees
consistent view inconsistencies in its own operations
Cost Expensive with concurrent writes Cheaper — guarantees only for one
client at a time
Key Points
• No reference to real time or wall-clock order — only program order must be preserved per
process.
• All processes must see the SAME interleaving of operations, even if that interleaving differs
from real-time ordering.
• A data store is sequentially consistent if any process's write is eventually visible to all others in
the same order.
Example (Fig. 7-5 from Tanenbaum, p. 283)
P1 writes x=a, P2 writes x=b. Both P3 and P4 read b first, then a. This is VALID — P2's write appears
to precede P1's for all processes, even though P1 wrote first in real time. It is only invalid if P3 sees (b,
then a) while P4 sees (a, then b) — different orderings violate sequential consistency.
Definition
If a process reads the value of a data item x, any successive read operation on x
by that process will always return that same value or a more recent value.
A client never 'goes back in time'.
Example
A user reads his email in San Francisco and sees messages M1, M2, M3. He travels to New York and
connects to a different replica. Monotonic-read consistency guarantees the New York replica shows at
least M1, M2, M3 — he will never see a state where those messages have disappeared.
Notation: WS(x1; x2) — the write set at L1 must be a subset of the write set at L2 before the second
read.
6. Process Resilience and Recovery
Reliability System runs continuously without failure over a time interval. A system down
for 1ms every hour is 99.9999% available but still unreliable.
Safety When a system temporarily fails, nothing catastrophic happens. Critical for
nuclear plant controllers and spacecraft.
Maintainability How easily a failed system can be repaired. Highly maintainable systems
recover fast, boosting availability.
1. Information redundancy — extra bits added to allow recovery from garbled bits. E.g., Hamming
codes added to transmitted data to recover from noise.
2. Time redundancy — an action is performed and, if it fails, performed again. Used in
transactions: if a transaction aborts, it can be redone with no harm.
3. Physical redundancy — extra equipment or processes are added. E.g., Triple Modular
Redundancy (TMR) uses three copies of each device plus voters to mask any single failure.
6.5 Process Groups — Design Issues
📊 Tanenbaum Fig. 8-3 (Book p. 329) — (a) Communication in a flat group. (b) Communication in a simple
hierarchical group.
Flat Groups
• All processes are equal — no single coordinator.
• No single point of failure: if one process crashes, the group continues (just smaller).
• Disadvantage: collective decision-making is complex — votes must be taken, incurring delay
and overhead.
Hierarchical Groups
• One process is the coordinator; others are workers.
• Coordinator makes decisions efficiently without consulting everyone.
• Disadvantage: loss of coordinator halts the entire group — a single point of failure.
6.6 Recovery
Checkpointing (Backward Error Recovery)
• The system periodically saves its state to stable storage.
• On failure, the system rolls back to the last consistent checkpoint — called a recovery line.
• Messages sent after the checkpoint must be replayed using message logging.
• Problem: finding a globally consistent checkpoint (recovery line) across all processes is non-
trivial due to messages in transit at the time of the checkpoint.
• The domino effect: if checkpoints are not properly coordinated, rolling back one process may
force others to also roll back, cascading to the start.
Message Logging
• Logs all messages to stable storage. On failure, replay logged messages to reach the pre-
failure state.
• Optimistic logging: log messages asynchronously (faster, but orphan messages may appear
after recovery).
• Pessimistic logging: flush logs synchronously before proceeding (slower, but guarantees
consistency).
7. Sequential and Release Consistency Models with
Examples
P1 P2 P3
Sequential consistency allows 90 valid orderings (any interleaving that preserves each process's
program order). Example valid signatures (concatenation of each process's print output):
• 111111 — P1 fully executes, then P2, then P3. Output: P1 prints (1,1), P2 prints (1,1), P3 prints
(1,1). Signature: 111111.
• 100110 — one valid interleaving where P1 sees y=0, z=0 (prints 00), etc.
Signature 001001 is INVALID — it would require P1 to print before P2/P3 start, but also P3 to complete
before P1 starts, which is contradictory.
The contract: all processes must accept any of the 90 valid results as correct program behavior.
📊 Tanenbaum Fig. 7-10 (Book p. 287) — A valid event sequence for entry consistency — P1 acquires x
then y; P2 acquires x only; P3 acquires y only.
Core Rules
4. Acquire rule — before a process completes an ACQUIRE, all remotely performed updates to the
guarded shared data must be made visible. No acquire may complete until all pending writes
from others have propagated.
5. Exclusive release rule — before another process can ACQUIRE a variable in exclusive mode,
no other process may hold it (even in non-exclusive mode).
6. Non-exclusive acquire rule — a process wanting to acquire in non-exclusive mode must first
check with the owner for the most recent copy of the guarded data.
Example (Fig. 7-10, Tanenbaum p. 287)
• P1 does acquire(x), writes x=a, then acquire(y), writes y=b, then release both.
• P2 does acquire(x) — sees x=a (correct, because P1 released x). P2 does NOT acquire y, so it
may see y=NIL. This is correct behavior under release/entry consistency.
• P3 does acquire(y) — sees y=b (correct, because P1 released y before P3 acquired it).
The key advantage: P2 does not need to see y's update because it never acquired the lock for y. This
eliminates unnecessary synchronization overhead compared to sequential consistency.
8. Types of Failures and K-Fault Tolerance
Crash (Fail-Stop) Server halts prematurely and was working OS kernel panic
correctly until it stopped. Nothing heard from it requiring reboot
afterward.
Omission — Receive Server never receives the incoming request (no No listener on socket
thread listening). Server state is unaffected.
Omission — Send Server did the work but fails to send the reply Buffer overflow on
(e.g., send buffer overflow). response
Timing (Performance) Server responds but outside the specified time Isochronous stream
interval — too slow or too fast. buffer overflow
Response — Value Server provides a wrong reply to a request. Search engine returns
irrelevant results
Arbitrary (Byzantine) Most severe. Server produces output it should Malicious collusion
never have produced, which cannot be detected between faulty nodes
as wrong. May even collude with other faulty
servers to produce wrong answers.
Additional categories:
• Fail-silent — server stops but doesn't announce it; others may mistake it for being slow.
• Fail-safe — server produces obviously wrong output (recognizable as junk) — a benign form of
arbitrary failure.
Definition
A system is said to be k fault tolerant if it can survive faults in k components
and still meet its specifications (Tanenbaum, p. 331).
Failure Model Replicas Required Reasoning
Precondition: All requests must arrive at all replicas in the same order — this is the atomic multicast
problem, discussed in Section 8.2.2.
9. Google File System (GFS) — Cluster-Based Distributed
File System
Tanenbaum Chapter 11 covers GFS as the primary example of a cluster-based DFS. HDFS (Hadoop
Distributed File System) is architected on the same principles. The GFS design is described in
Ghemawat et al. (2003).
📊 Tanenbaum Fig. 11-5 (Book p. 498) — The organization of a Google cluster of servers — single master
with multiple chunk servers.
9.2 Architecture
Single GFS Master
• Manages all metadata: namespace (path names → inodes), file-to-chunk mappings, and chunk
locations.
• Maintains the entire namespace table in main memory for fast access.
• Does NOT maintain real-time accurate chunk locations — instead polls chunk servers
periodically (simplifies design enormously).
• Updates to the namespace are logged to persistent storage. When the log is too large, a
checkpoint is created for fast restart.
Relation to HDFS
HDFS mirrors GFS architecture:
GFS Master → HDFS NameNode
GFS Chunk Servers → HDFS DataNodes
GFS 64 MB chunks → HDFS 128 MB blocks (default)
Same principle: NameNode handles metadata, DataNodes handle data I/O.
10. Transfer Policy (Sender-Initiated)
A transfer policy determines WHEN a process should be migrated. Tanenbaum discusses three main
policies:
Mechanism
11. When a new process is created, the local machine checks its own load level.
12. If local load > upper threshold (overloaded): the machine probes randomly selected remote
machines.
13. If a probed machine's load < lower threshold: the new process is sent there.
14. If after N probes no suitable machine is found: the process runs locally.
Advantages
• Simple to implement — the overloaded machine takes initiative.
• Effective at distributing load away from hot-spot machines.
Disadvantages
• When many nodes are simultaneously overloaded, all of them probe the same set of lightly-
loaded machines, flooding them and causing the very overload they are trying to avoid —
oscillation/instability.
• Under high system-wide load, probing overhead itself becomes a significant burden.
Receiver-Initiated Good under high load High when lightly loaded (idle
nodes broadcast)
These are three of the four client-centric consistency models from Bayou (Terry et al., 1994), described
in Tanenbaum Chapter 7.3. They provide guarantees for a single client even when accessing different
replicas over time.
Guarantee: A client will never 'go back in time' — once it has seen a value of x, it will never see an
older version.
Notation: WS(x1; x2) — the write set at L1 must be a subset of the write set at L2 before the second
read.
Example: User reads email in San Francisco (sees M1, M2, M3). Travels to New York and connects to
a different replica. Monotonic reads guarantees he will see at least M1, M2, M3 — the New York replica
must have propagated those writes before serving the user.
Guarantee: Writes by the same process are applied in the order they were issued, everywhere. A copy
of x may only receive write W2 after it has first received write W1.
Note: Resembles data-centric FIFO consistency, but applies to a single client rather than a collection of
concurrent processes.
Example: A software library is updated. Version 2 depends on Version 1. Monotonic-write consistency
ensures Version 2 is applied to a copy only after Version 1 has already been applied there. Without
this, Version 2 might overwrite a stale copy, producing a corrupted library.
11.3 Read Your Writes
📊 Tanenbaum Fig. 7-14 (Book p. 294) — (a) A data store that provides read-your-writes consistency. (b) A
data store that does NOT.
Guarantee: A process always sees the effects of its own writes, no matter which replica it reads from
next.
Example 1 (Web page): A user edits and saves a Web page. When he refreshes his browser, he
should see the updated version — not a cached stale copy. Read-your-writes ensures the cache is
invalidated, so the updated file is always fetched.
Example 2 (Password change): A user changes their library password. Without read-your-writes, the
new password may not yet have propagated to the authentication server — the user gets locked out
temporarily. Read-your-writes ensures the new password takes effect immediately for that user.
Example: User reads article A in a newsgroup. Then posts response B. Writes-follow-reads ensures B
is stored at a copy only after A is also stored there — readers will always see the original article before
any responses to it.
12. Design and Implementation Issues of DSM
Distributed Shared Memory (DSM) creates the illusion of a single shared address space across
physically distributed machines. Processes can use normal read/write operations without explicit
message passing. Tanenbaum references this as a foundational consistency topic.
Granularity DSM is typically implemented at the page level. The false sharing
problem: two processes access different variables on the same page —
every access causes a page transfer even though variables are
unrelated. Smaller granularity reduces false sharing but increases
overhead.
Replication & Caching Pages can be replicated for read performance. Challenge: keeping
replicas consistent. On a write, all other copies must be invalidated or
updated.
Page Ownership Fixed ownership: owner never changes — writes always go to owner
(simple but creates bottleneck). Dynamic ownership: ownership migrates
to the current writer (reduces bottleneck but complicates tracking).
Update vs. Invalidate Write-invalidate: all other copies are invalidated on a write — next read
triggers a fetch. Efficient for write-once-then-many-reads patterns. Write-
update: all copies receive the new value immediately — efficient when
multiple processes frequently read a written item.
False Sharing Two processes on different machines write to different variables on the
same page → constant page transfers and invalidations, even though
they don't actually share data. Solution: careful data layout, or multiple-
writer protocols (TreadMarks) that allow concurrent writers on one page
and merge diffs at synchronization points.
Thrashing A page is requested back and forth between two machines so rapidly that
the transfer overhead overwhelms any benefit from DSM. Requires
careful application design and possibly reducing sharing frequency.
Required Mechanisms
• Group creation and deletion
• Join/leave operations — must be synchronized with the message stream (a joining process
must receive all subsequent messages; a leaving process must stop receiving messages, and
others must stop receiving from it)
• Failure detection — crashed members do not announce departure; timeout-based detection is
required
• Group rebuild protocol — if too many members crash, some process must take initiative to
rebuild the group
FIFO-Ordered Messages from the same sender arrive in the order they were sent.
Causally-Ordered Causally related messages are delivered in causal order (weaker than
total order).
Totally Ordered All messages are delivered to ALL processes in exactly the same
global order, regardless of sender or timing.
The Problem
Without total ordering, replicated databases can become inconsistent:
• Customer deposits $100 (account: $1,000). Bank adds 1% interest. Both updates must go to
both replicas.
• San Francisco replica applies: deposit first ($1,100), then interest ($1,111).
• New York replica applies: interest first ($1,010), then deposit ($1,110).
• Result: $1,111 vs $1,110 — two different values for the same account. Inconsistency!
The solution: both updates must be applied in the same order at all replicas. Which order does not
matter for consistency — only that the order is identical.
Key Characteristics
• System knows (or estimates) task characteristics — computation time, data requirements,
communication patterns — before execution.
• Tasks are assigned to processors to minimize total execution time or maximize CPU utilization.
• Considers task dependencies, communication costs, and processor capabilities.
• No runtime migration — tasks stay where assigned.
Example
A parallel weather simulation is divided into sub-problems based on geographic regions. Each sub-
problem is pre-assigned to a specific node based on data locality. No runtime redistribution occurs.
Limitations
• Fails when actual task workloads differ significantly from estimates.
• Cannot adapt to runtime events: node failures, unexpected load spikes, variable task lengths.
Location Policy Which machine to migrate to? Random probing; polling; central
directory service
Fault Handling Poor — does not react to node Good — can redistribute work on
failures failure detection
Reference: All content sourced directly from Tanenbaum, A.S. & Van Steen, M. (2007). Distributed Systems:
Principles and Paradigms, 2nd Edition. Prentice Hall. Figure numbers and page numbers refer to this edition.