Label: This guide is built from the mapped archived 2018 TOC for CACS352 (mapped course code BCA355), located at the course outline. It preserves every source unit and numbered topic (1.1–9.5) in order. It is NOT a new 2025 detailed syllabus and does not claim official 2025 status.
Course overview
Distributed System introduces computing where multiple autonomous computers communicate over a network to appear as a single coherent system. The course covers characteristics and design goals, types of distributed systems, architectures and middleware, processes (threads, virtualization, clients, servers, code migration), communication (foundations, RPC, message-oriented, multicast, Java RMI/MPI), naming, coordination (clocks, logical clocks, mutual exclusion, elections, location, event matching, gossip), consistency and replication, fault tolerance, and security. Class load: 4 hrs/week (Theory 3, Tutorial 1), 3 credits.
Learning outcomes (derived only from the approved TOC)
By the end of this course, a student should be able to:
- List characteristics and design goals of distributed systems and give types with examples.
- Use the World Wide Web as a case study of a distributed system.
- Describe architectural styles, middleware organization, system architecture, and example architectures.
- Explain threads, virtualization, clients, servers, and code migration.
- Describe communication foundations, RPC, message-oriented communication, and multicast communication.
- Discuss the case study Java RMI and Message Passing Interface (MPI).
- Distinguish names, identifiers, and addresses; explain structured naming and attribute-based naming.
- Discuss the Global Name Service case study.
- Explain clock synchronization, logical clocks, mutual exclusion, election algorithms, location systems, distributed event matching, and gossip-based coordination.
- Distinguish data-centric and client-centric consistency models; explain replica management, consistency protocols, and web caching/replication.
- Explain fault tolerance, process resilience, reliable client-server and group communication, distributed commit, and recovery.
- Describe security, secure channels, access control, secure naming, and security management.
Unit 1: Introduction
Teaching hours: 4
Topics in outline order
- 1.1 Characteristics
- 1.2 Design Goals
- 1.3 Types of Distributed Systems
- 1.4 Case Study: The World Wide Web
1.1 Characteristics
Plain-language definition and why it matters. A characteristic is a defining property of distributed systems. Knowing them helps students recognize what makes a system "distributed" and what problems (concurrency, partial failure, no global clock) designers must handle.
Core theory. Key characteristics: resource sharing, openness, concurrency, scalability, fault tolerance, and transparency. Transparency types: access, location, migration, relocation, replication, concurrency, failure, persistence, performance. A distributed system is a collection of independent computers that appears to users as a single coherent system (Coulouris et al. definition).
Syntax / notation. Conceptual; transparency is a design property, not code.
Worked example. A student uses Google Docs: multiple users edit concurrently (concurrency), data is replicated across datacenters (replication transparency), and if one server fails, the doc remains available (fault tolerance) — all appearing as one service (transparency).
Realistic use case. An ATM network lets customers withdraw from any machine as if from one bank (location and access transparency), 24×7 (availability), even if a branch server fails (fault tolerance).
Comparison table.
| Characteristic | Meaning |
|---|---|
| Resource sharing | hardware/software/resources usable across machines |
| Openness | extensible via standard interfaces |
| Concurrency | many users/processes act at once |
| Scalability | grows by adding machines |
| Fault tolerance | keeps working despite failures |
| Transparency | hides distribution from users |
Common mistakes / limitations. Assuming distribution means "many servers in one room" (it implies networked autonomous machines); overlooking that transparency is a goal, not a free property (it costs complexity/performance).
Exam-ready answer points. Define distributed system; list characteristics with one-line meanings; name transparency types.
Self-check questions with answers.
- What does transparency mean in a distributed system? Answer: hiding the distribution (location, access, failure, etc.) from users.
- Name two characteristics besides transparency. Answer: concurrency and fault tolerance (or scalability, openness, resource sharing).
1.2 Design Goals
Plain-language definition and why it matters. Design goals are the objectives a distributed system should achieve. They matter because they drive architecture choices and trade-offs (e.g., consistency vs availability).
Core theory. Goals: connectivity (users/resources communicate), transparency (as above), scalability (size/geography/administration), consistency (replicas agree), fault tolerance (continue despite failure), quality of service (latency, throughput, security), and security (confidentiality, integrity, availability). Trade-offs exist: e.g., strong consistency can reduce availability under partitions (CAP intuition).
Syntax / notation. Conceptual; no code syntax.
Worked example. Designing a global video platform: scalability (add edge caches), consistency (view counts eventually consistent OK), QoS (low latency streaming), security (DRM, access control).
Realistic use case. A Nepal-wide online exam portal must scale to thousands of concurrent students, remain available if a regional node fails, and keep results consistent.
Comparison table.
| Goal | Concern |
|---|---|
| Connectivity | nodes can reach each other |
| Transparency | hide distribution |
| Scalability | add nodes/users without redesign |
| Consistency | replicas show same data |
| Fault tolerance | survive node/network failure |
| QoS | latency, throughput guarantees |
| Security | protect data and access |
Common mistakes / limitations. Treating all goals as equally achievable simultaneously; ignoring CAP-style trade-offs.
Exam-ready answer points. List design goals; explain scalability, transparency, consistency, fault tolerance; mention trade-offs.
Self-check questions with answers.
- Name three design goals of distributed systems. Answer: scalability, fault tolerance, transparency (any three).
- What is a common trade-off among these goals? Answer: consistency vs availability/performance (e.g., strong consistency costs latency).
1.3 Types of Distributed Systems
Plain-language definition and why it matters. Distributed systems come in styles suited to different workloads. Knowing types helps choose the right architecture (e.g., cluster for computing, grid for sharing, P2P for file sharing).
Core theory. Types: computational clusters, grids, clouds, peer-to-peer (P2P) systems, mobile/ubiquitous systems, distributed information systems (WWW, DNS), embedded/distributed real-time systems, cluster vs grid vs cloud. Clusters: tightly coupled machines, single admin. Grids: loosely coupled, geographically distributed, resource sharing. Clouds: on-demand pooled resources, pay-as-you-go. P2P: peers act as clients and servers (e.g., BitTorrent).
Syntax / notation. Conceptual; example P2P: node A requests file, multiple peers supply pieces.
Worked example. A research team needs heavy simulation: use a cluster (tightly coupled, fast interconnect). A global volunteer computing project (e.g., SETI-like): use a grid (loosely coupled, donated machines).
Realistic use case. A college uses a local cluster for lab computing; students store files on a cloud (Google Drive) for access anywhere.
Comparison table.
| Type | Coupling | Admin | Example |
|---|---|---|---|
| Cluster | tight | single | lab Beowulf cluster |
| Grid | loose | multiple | volunteer computing |
| Cloud | pooled | provider | AWS, Google Cloud |
| P2P | decentralized | none | BitTorrent, blockchain |
Swipe to see all columns
Common mistakes / limitations. Confusing grid and cloud (grid = shared owned resources; cloud = on-demand rented); assuming P2P has no central coordination at all (many P2P use trackers/bootstrappers).
Exam-ready answer points. List types; contrast cluster/grid/cloud/P2P; give one example each.
Self-check questions with answers.
- What is a cluster? Answer: tightly coupled machines under single administration working together.
- How does a cloud differ from a grid? Answer: cloud offers on-demand pooled resources (pay per use); grid shares geographically distributed owned resources.
1.4 Case Study: The World Wide Web
Plain-language definition and why it matters. The Web is the most familiar distributed system: browsers (clients), web servers, DNS, CDNs, and hyperlinked resources across the Internet. Studying it grounds abstract concepts in a concrete example.
Core theory. Web architecture: user runs a browser (client); URL identifies a resource; DNS resolves the host name to an IP; HTTP/HTTPS transfers HTML/resources; web server hosts content; CDN caches content near users; cookies/sessions maintain state; search engines index pages. The Web is heterogeneous, scalable, and uses URIs as names.
Syntax / notation. URL format: scheme://host:port/path?query#fragment, e.g., https://example.edu/page?id=1.
Worked example. Loading https://example.edu/course: browser resolves DNS to IP, opens TCP/HTTPS, sends GET /course, server returns HTML with links, browser renders; images may come from a CDN edge cache.
Realistic use case. A university portal serves students nationwide via web servers plus a CDN so pages load faster regionally.
Comparison table.
| Web part | Role |
|---|---|
| Browser | client/user agent |
| DNS | name → IP resolution |
| Web server | stores/serves resources |
| HTTP | transfer protocol |
| CDN | caches content near users |
| URL/URI | names a resource |
Common mistakes / limitations. Treating the Web as one server (it's distributed); assuming HTTP is stateful (cookies/sessions add state); ignoring that DNS itself is a distributed naming system.
Exam-ready answer points. Describe Web as a distributed system; name browser, DNS, web server, HTTP, CDN; explain URL parts.
Self-check questions with answers.
- Which component resolves a host name to an IP? Answer: DNS.
- What does HTTP do in the Web? Answer: transfers resources between client and server.
Key terms — Unit 1
distributed system · transparency · concurrency · scalability · fault tolerance · openness · consistency · QoS · security · cluster · grid · cloud · peer-to-peer · World Wide Web · browser · DNS · HTTP · CDN · URL
Unit summary — Unit 1
Distributed systems are networked autonomous computers appearing as one coherent system, characterized by resource sharing, openness, concurrency, scalability, fault tolerance, and transparency. Design goals include connectivity, transparency, scalability, consistency, fault tolerance, QoS, and security, with trade-offs. Types include clusters, grids, clouds, and P2P. The World Wide Web is a canonical case study (browser, DNS, web server, HTTP, CDN).
Unit 2: Architecture
Teaching hours: 4
Topics in outline order
- 2.1 Architectural Styles
- 2.2 Middleware organization
- 2.3 System Architecture
- 2.4 Example Architectures
2.1 Architectural Styles
Plain-language definition and why it matters. Architectural styles are recurring ways to structure components and connectors in a distributed system. They matter because they determine coupling, scalability, and how components interact.
Core theory. Styles: centralized (one server, many clients), decentralized (peer-to-peer), hierarchical (tree of servers), object-based (CORBA/DCOM), layered (presentation, application, data tiers), client-server, multi-tier (n-tier), service-oriented (SOA), event-based (publish/subscribe), and micro-services (fine-grained services over HTTP/REST, lightweight). Centralized is simple but a single point of failure; decentralized scales but is harder to manage; layered separates concerns; event-based decouples producers and consumers.
Syntax / notation. Conceptual; layers diagram: client → presentation tier → application tier → data tier.
Worked example. An online store: browser (presentation), app server (application logic), database (data) — a 3-tier layered architecture; plus event-based notifications (order placed → email service).
Realistic use case. A bank uses multi-tier: web front-end, application server with business rules, and a back-end database; SOA exposes customer services to mobile and web channels.
Comparison table.
| Style | Coupling | Strength | Weakness |
|---|---|---|---|
| Centralized | high | simple to manage | single point of failure |
| Decentralized/P2P | low | scalable, no SPOF | complex coordination |
| Layered | medium | separation of concerns | latency through layers |
| Event-based | low | loose coupling | harder to trace flow |
| SOA / micro-services | medium | independent deployment | operational complexity |
Swipe to see all columns
Common mistakes / limitations. Assuming one style fits all; ignoring that micro-services increase operational overhead (deployments, monitoring).
Exam-ready answer points. List architectural styles; contrast centralized vs decentralized vs layered; explain client-server and event-based.
Self-check questions with answers.
- Name two architectural styles. Answer: client-server and peer-to-peer (or layered, SOA, event-based).
- What is a weakness of centralized architecture? Answer: single point of failure.
2.2 Middleware organization
Plain-language definition and why it matters. Middleware is the layer between operating systems and applications that enables communication, coordination, and integration in distributed systems. It matters because it hides network/OS heterogeneity and provides reusable services.
Core theory. Middleware sits above the network/OS and below applications. Organization categories: RPC-based (request/reply), message-oriented (queues, publish/subscribe), object-based (CORBA, DCOM, RMI), transaction processing monitors (TP monitors), and web services/RESTful middleware. Services provided: naming/directory, security, transaction, concurrency, persistence. Examples: CORBA (object), MOM/IBM MQ (message), Apache Kafka (event streaming), gRPC (RPC), SOAP/REST (web services).
Syntax / notation. Conceptual; middleware call: client → stub → middleware → skeleton → server.
Worked example. A travel app: mobile client calls a SOAP web service (middleware) to book a flight; the middleware handles transport, security, and the airline's backend reservation system.
Realistic use case. A payment gateway uses a message queue as middleware so payment requests are reliably processed even if the bank system is temporarily slow.
Comparison table.
| Middleware kind | Communication | Example |
|---|---|---|
| RPC | request/reply | gRPC, Java RMI |
| Message-oriented | async queues/pub-sub | RabbitMQ, Kafka |
| Object-based | remote object calls | CORBA, RMI |
| Web services | HTTP/XML or JSON | SOAP, REST |
Common mistakes / limitations. Treating middleware as "just a network"; ignoring that middleware adds latency and its own failure points; assuming all middleware is synchronous.
Exam-ready answer points. Define middleware; list organization types; give examples; explain what services middleware provides.
Self-check questions with answers.
- Where does middleware sit? Answer: between the OS/network and applications.
- Name one RPC middleware and one message middleware. Answer: gRPC/RMI (RPC), RabbitMQ/Kafka (message).
2.3 System Architecture
Plain-language definition and why it matters. System architecture is the overall structure: components, their relationships, deployment across nodes, and how they interact. It matters because it determines performance, reliability, and evolvability.
Core theory. Components: clients, servers, proxies, gateways, name services, databases, message brokers. Deployment: single-tier, two-tier (client/server), three-tier (web/app/db), n-tier. Communication: synchronous vs asynchronous; tight vs loose coupling. Architecture addresses hardware mapping (which component runs on which node), network topology, and failure domains.
Syntax / notation. Box-and-line diagrams: clients on left, firewalls/load balancers middle, app/db servers right; arrows show calls.
Worked example. A university admission portal: applicants' browsers → load balancer → web servers → application servers → central database; an LDAP directory for authentication; email server for notifications.
Realistic use case. An e-commerce site separates catalog (read-heavy, cached) from checkout (write, transactional) in its architecture.
Comparison table.
| Tier | Components |
|---|---|
| Single-tier | all on one machine |
| Two-tier | client + server (database) |
| Three-tier | client + app server + database |
| N-tier | additional service layers |
Common mistakes / limitations. Drawing architecture without failure domains (what if a node dies); ignoring network latency between tiers.
Exam-ready answer points. Define system architecture; list deployment tiers; name components; explain sync vs async communication.
Self-check questions with answers.
- What is a three-tier architecture? Answer: presentation (client), application (app server), data (database) on separate tiers.
- Name two components besides clients and servers. Answer: load balancer and name service (or database, message broker).
2.4 Example Architectures
Plain-language definition and why it matters. Example architectures show real patterns in production systems. They matter because they illustrate how styles and middleware combine to solve concrete problems.
Core theory. Examples: Web architecture (browser + DNS + web server + CDN), email (SMTP/IMAP/POP3, MTAs, mailboxes), DNS (hierarchical name resolution with root/TLD/authoritative servers), distributed file systems (NFS, AFS, HDFS), content delivery networks, and distributed object systems (CORBA). Each illustrates strengths (e.g., DNS hierarchy scales; HDFS stores large files across commodity nodes).
Syntax / notation. Email flow: MUA → submission → MTA → MTA → MDA → mailbox → IMAP/POP3 retrieval.
Worked example. DNS lookup for www.example.edu: resolver → root server → .edu TLD server → authoritative server for example.edu → IP address. Hierarchical and cached at each level.
Realistic use case. A video platform stores raw videos in HDFS-like distributed storage and serves viewers through a CDN.
Comparison table.
| Example | Key pattern | Strength |
|---|---|---|
| Web | client/server + CDN | global scale |
| DNS | hierarchical naming | scales, decentralized |
| store-and-forward (MTAs) | asynchronous, reliable | |
| HDFS | distributed storage | large files, commodity nodes |
Common mistakes / limitations. Confusing DNS with a single database (it's distributed and cached); assuming email is real-time (store-and-forward has delays).
Exam-ready answer points. List example architectures; explain DNS hierarchy and email store-and-forward; mention HDFS/CDN.
Self-check questions with answers.
- What pattern does DNS use? Answer: hierarchical name resolution (root → TLD → authoritative).
- How is email communication characterized? Answer: store-and-forward via MTAs (asynchronous).
Key terms — Unit 2
architectural style · centralized · decentralized · layered · client-server · multi-tier · SOA · micro-services · event-based · middleware · RPC · message-oriented · object-based · web services · system architecture · tiers · DNS · email · HDFS · CDN
Unit summary — Unit 2
Architectural styles (centralized, decentralized, layered, client-server, SOA, micro-services, event-based) structure components and connectors. Middleware (RPC, message-oriented, object-based, web services) lies between OS and applications and provides naming, security, transaction, and concurrency services. System architecture covers deployment tiers (single/two/three/n-tier) and components. Examples: Web, DNS, email, HDFS, CDN.
Unit 3: Processes
Teaching hours: 6
Topics in outline order
- 3.1 Threads
- 3.2 Virtualization
- 3.3 Clients
- 3.4 Servers
- 3.5 Code Migration
3.1 Threads
Plain-language definition and why it matters. A thread is a lightweight unit of execution within a process, sharing the process's memory. Threads matter in distributed systems because servers handle many clients concurrently, and threads let one process serve multiple requests at once.
Core theory. Process = program in execution with its own address space; thread = execution stream within a process, sharing code/data/heap but with its own stack/Program Counter. User-level threads (managed by a library, fast, invisible to OS) vs kernel-level threads (OS knows them, can run on multiple cores, slower context switch). Multithreading models: many-to-one, one-to-one, many-to-many. Thread issues: race conditions, synchronization (mutexes, semaphores), deadlock.
Syntax / notation. Pthreads-style: pthread_create(&tid, NULL, func, arg); Java: new Thread(runnable).start().
Worked example. A web server spawns a thread per request: thread A reads request, thread B queries DB, thread C sends response — all sharing the server's connection pool and cache.
Realistic use case. A chat server keeps one thread per connected client so messages are handled concurrently.
Comparison table.
| Process | Thread | |
|---|---|---|
| Address space | own | shared with process |
| Creation cost | heavy | light |
| Context switch | slow | fast |
| Isolation | strong | weak (shared memory) |
Common mistakes / limitations. Forgetting synchronization → race conditions; assuming threads on one core run truly in parallel (they interleave); too many threads cause overhead.
Exam-ready answer points. Define thread vs process; contrast user-level vs kernel-level; list threading models; name synchronization problems.
Self-check questions with answers.
- What do threads within a process share? Answer: code, data, heap (address space); each has its own stack/PC.
- Name one threading model. Answer: many-to-one / one-to-one / many-to-many.
3.2 Virtualization
Plain-language definition and why it matters. Virtualization abstracts physical resources (CPU, memory, storage, network) into multiple virtual machines/containers. It matters because distributed systems and clouds run many isolated workloads on shared hardware.
Core theory. Hypervisor (VMM) sits between hardware and VMs: Type-1 (bare metal, e.g., Xen, ESXi) and Type-2 (hosted, e.g., VirtualBox, VMware Workstation). Each VM runs its own guest OS. Containers (Docker) share the host OS kernel, lighter than VMs. Benefits: isolation, consolidation, migration, snapshots. Overhead: CPU/memory cost of hypervisor and guest OS.
Syntax / notation. Conceptual; Dockerfile example line: FROM ubuntu:22.04.
Worked example. A cloud provider runs 20 VMs on one physical server via a Type-1 hypervisor; each customer's VM is isolated and can be migrated to another host for maintenance.
Realistic use case. A developer uses Docker containers to run a distributed app locally with consistent environment across team machines.
Comparison table.
| VM | Container | |
|---|---|---|
| OS | full guest OS | shares host kernel |
| Isolation | strong | process-level |
| Weight | heavy | light |
| Boot time | seconds/minutes | milliseconds |
Common mistakes / limitations. Confusing VMs and containers (containers are not full virtualization); ignoring hypervisor overhead; assuming containers are as isolated as VMs.
Exam-ready answer points. Define virtualization and hypervisor; contrast Type-1 vs Type-2; explain VM vs container; list benefits and overhead.
Self-check questions with answers.
- What is a hypervisor? Answer: software that creates and runs virtual machines (VMM).
- How do containers differ from VMs? Answer: containers share the host OS kernel; VMs run a full guest OS.
3.3 Clients
Plain-language definition and why it matters. A client is a process/application that requests services from servers. Clients matter because they initiate interactions and present the user interface in client-server systems.
Core theory. Thin client: little logic, relies on server (web browser). Thick/fat client: substantial local logic (desktop app). Mobile client: app on phone. Client properties: initiates requests, waits for responses, may cache, handles user interaction. Client-side concerns: responsiveness, caching, offline support, authentication state.
Syntax / notation. Conceptual; HTTP client request GET /resource HTTP/1.1.
Worked example. Thin client: a bank's web banking site (browser does little, server does all). Thick client: Photoshop-like desktop app (heavy local computation, syncs to server occasionally).
Realistic use case. A Nepali e-commerce app is a thick mobile client that caches the product catalog locally and syncs orders to the server.
Comparison table.
| Client type | Logic location | Example |
|---|---|---|
| Thin | mostly server | web browser |
| Thick/fat | mostly client | desktop application |
| Mobile | client + sync | mobile app |
Common mistakes / limitations. Assuming thin clients need no local logic (they still render and validate); overlooking mobile constraints (battery, intermittent network).
Exam-ready answer points. Define client; contrast thin vs thick vs mobile; list client concerns.
Self-check questions with answers.
- What does a client do? Answer: requests services from servers and presents UI/interaction.
- Difference between thin and thick client? Answer: thin relies on server; thick has substantial local logic.
3.4 Servers
Plain-language definition and why it matters. A server is a process that waits for and fulfills client requests. Servers matter because they provide the shared resources (files, computation, data) in distributed systems.
Core theory. Iterative server: handles one request at a time (simple, blocks others). Concurrent server: handles multiple requests via threads/processes (fork per request or thread pool). Stateless vs stateful server (stateless scales better; stateful remembers client context). Server concerns: thread pool sizing, connection limits, keep-alive, graceful shutdown, load handling.
Syntax / notation. Pseudo: while (true) { conn = accept(); handle(conn); } (iterative) vs spawn thread/thread pool (concurrent).
Worked example. Iterative: an FTP-like server serving one client at a time. Concurrent: a web server with a thread pool of 200 handling hundreds of simultaneous browsers.
Realistic use case. A high-traffic news site uses a concurrent server (thread pool + keep-alive) so many readers don't queue.
Comparison table.
| Server type | Concurrency | Scalability |
|---|---|---|
| Iterative | one at a time | low |
| Concurrent (thread/process per request) | many | medium |
| Thread pool | many, bounded | high |
Common mistakes / limitations. Iterative server under load queues all clients; unbounded thread creation exhausts memory; stateful servers don't scale behind load balancers easily.
Exam-ready answer points. Define server; contrast iterative vs concurrent vs thread pool; stateless vs stateful; list server concerns.
Self-check questions with answers.
- What is an iterative server? Answer: handles one client request at a time.
- Why are stateless servers easier to scale? Answer: no client context to replicate/migrate across servers.
3.5 Code Migration
Plain-language definition and why it matters. Code migration moves a program's execution from one machine to another. It matters for load balancing, mobile agents, and running computation near data.
Core theory. Mechanisms: transfer code at process start (load code then run), migrate a running process (transfer state: code, PC, stack, open resources), mobile agents (autonomous programs that travel between hosts). Challenges: transferring execution state (stack, registers, open files/sockets), architecture differences, security (running foreign code), and resumption consistency. Approaches: weak mobility (code + data, restart at destination) vs strong mobility (migrate running execution state).
Syntax / notation. Conceptual; agent pseudocode: at(hostA) { travel(hostB); continue execution }.
Worked example. A mobile agent collects sensor readings: starts at gateway, travels to each sensor node, aggregates locally, returns results — reducing network traffic.
Realistic use case. Grid computing migrates computation jobs to idle nodes to balance load.
Comparison table.
| Mobility | What moves | Resumes? |
|---|---|---|
| Weak | code + data | restarts at destination |
| Strong | code + execution state | continues where it left off |
Common mistakes / limitations. Ignoring heterogeneous architectures (binary won't run elsewhere); security risk of executing migrated code (sandboxing needed); losing open sockets/files on migration.
Exam-ready answer points. Define code migration; explain weak vs strong mobility; list challenges (state transfer, security, heterogeneity).
Self-check questions with answers.
- Difference between weak and strong mobility? Answer: weak restarts at destination; strong continues execution state.
- Name one challenge of code migration. Answer: transferring execution state (stack/PC/open resources) or security.
Key terms — Unit 3
thread · process · user-level thread · kernel-level thread · many-to-one · one-to-one · many-to-many · race condition · mutex · hypervisor · Type-1 · Type-2 · VM · container · thin client · thick client · iterative server · concurrent server · thread pool · stateless · stateful · code migration · weak mobility · strong mobility · mobile agent
Unit summary — Unit 3
Threads are lightweight executions within a process (user vs kernel-level; synchronization issues). Virtualization (hypervisors Type-1/Type-2, VMs vs containers) abstracts hardware for isolation and consolidation. Clients (thin/thick/mobile) request services; servers (iterative/concurrent/thread-pool; stateless/stateful) fulfill them. Code migration moves execution (weak: restart; strong: continue) across machines for load balancing and mobile agents.
Unit 4: Communication
Teaching hours: 5
Topics in outline order
- 4.1 Foundations
- 4.2 Remote Procedure Call
- 4.3 Message-Oriented Communication
- 4.4 Multicast Communication
- 4.5 Case Study: Java RMI and Message Passing Interface (MN)
4.1 Foundations
Plain-language definition and why it matters. Communication foundations are how processes exchange messages over a network. They matter because every distributed system is built on message passing.
Core theory. Layered network model (OSI: 7 layers; TCP/IP: 4 layers — link, internet, transport, application). Sockets: endpoint for communication (IP address + port), types: stream (TCP, reliable, connection-oriented) and datagram (UDP, unreliable, connectionless). UDP vs TCP: TCP guarantees delivery/order (handshake, ACKs, retransmission), UDP is faster but lossy. Ports identify services (80 HTTP, 443 HTTPS, 25 SMTP). Data representation/marshalling: converting data to bytes for transfer (endianness: big vs little endian). Partial failure: network can fail while machines work.
Syntax / notation. Socket: <IP address, port>. TCP handshake: SYN → SYN-ACK → ACK.
Worked example. Client connects to 203.0.113.10:80 (TCP stream socket), sends HTTP request, receives response. Datagram: DNS query uses UDP port 53 (one request, one response, no connection).
Realistic use case. A video call uses UDP for media (speed, tolerates loss) and TCP for signaling (reliability).
Comparison table.
| TCP | UDP | |
|---|---|---|
| Reliable | yes | no |
| Connection | connection-oriented | connectionless |
| Order | guaranteed | not guaranteed |
| Speed | slower | faster |
| Use | web, file, email | DNS, streaming, VoIP |
Common mistakes / limitations. Assuming TCP = always better (UDP suits real-time); ignoring partial failure (network down while hosts up); forgetting endianness when marshalling integers across architectures.
Exam-ready answer points. Describe OSI/TCP/IP layers; explain sockets and ports; contrast TCP vs UDP; explain marshalling/endianness; mention partial failure.
Self-check questions with answers.
- What is a socket? Answer: communication endpoint identified by IP address + port.
- Difference between TCP and UDP? Answer: TCP reliable/ordered/connection-oriented; UDP unreliable/unordered/connectionless/faster.
4.2 Remote Procedure Call
Plain-language definition and why it matters. RPC lets a program call a procedure on a remote machine as if it were local. It matters because it simplifies distributed programming by hiding message passing behind a familiar call/return style.
Core theory. RPC model: client calls stub → stub marshals parameters → sends message → server stub unmarshals → calls procedure → returns result → marshal → client stub unmarshals → returns to client. Key elements: client stub, server stub, marshalling/unmarshalling, RPC runtime, port mapper/name service (to find the server), UUID/interface identifier. Semantics: at-least-once, at-most-once, exactly-once (exactly-once is hard); idempotency helps. One-way RPC (no reply). Callback RPC.
Syntax / notation. Interface definition language (IDL) declares procedures; generated stubs handle marshalling.
Worked example. A client calls getBalance(accountId) on a bank server. The client stub packs accountId, sends it, the server stub unpacks, looks up balance, returns the amount; client stub unpacks into a variable.
Realistic use case. A legacy mainframe exposes business logic via RPC so a modern web frontend can call calculateTax() remotely.
Comparison table.
| Local call | RPC | |
|---|---|---|
| Failure | rare | network/server can fail |
| Performance | fast | slower (marshalling + network) |
| Semantics | simple | at-least/at-most/exactly-once |
| Transparency | full | partial (failures visible) |
Common mistakes / limitations. Treating RPC as exactly like a local call (failures, latency, partial failure); not handling idempotency (retries may duplicate); ignoring the port mapper/name service needed to locate the server.
Exam-ready answer points. Explain RPC steps (client stub → marshal → send → server stub → unmarshal → call → return); name stubs, marshalling, port mapper; discuss failure semantics and idempotency.
Self-check questions with answers.
- What does a client stub do in RPC? Answer: marshals parameters and sends the request to the server.
- Why is exactly-once semantics hard? Answer: network failures and retries make it difficult to guarantee a procedure runs exactly once.
4.3 Message-Oriented Communication
Plain-language definition and why it matters. Message-oriented communication sends discrete messages between processes, often asynchronously via mailboxes/queues. It matters because it decouples senders and receivers in time and space.
Core theory. Persistent communication: messages stored in a queue/mailbox until received (survives receiver downtime). Transient: receiver must be active. Message-oriented middleware (MOM): point-to-point (queues) and publish/subscribe (topics). Operations: send, receive (blocking/non-blocking). Mailbox: multiple writers/readers; message passing primitives. Buffering: zero capacity, bounded, unbounded. Unlike RPC, no direct call/return; loosely coupled.
Syntax / notation. Conceptual: send(mailbox, message) / receive(mailbox).
Worked example. An order system: web frontend puts OrderPlaced messages on a queue; a worker service consumes them asynchronously and processes payments; if the worker is down, messages queue up.
Realistic use case. A notification service: many services publish to a topic; email/SMS subscribers receive asynchronously.
Comparison table.
| RPC | Message-oriented | |
|---|---|---|
| Coupling | tight (request/reply) | loose |
| Timing | synchronous usually | asynchronous possible |
| Intermediary | none/direct | queue/mailbox |
| Receiver must be active | yes | no (if persistent) |
Common mistakes / limitations. Assuming message delivery is instant (queues have latency); ignoring poison messages (bad messages block a queue); not acknowledging consumed messages (message redelivered repeatedly).
Exam-ready answer points. Define message-oriented communication; contrast persistent vs transient; explain point-to-point vs pub/sub; contrast with RPC; name send/receive and buffering.
Self-check questions with answers.
- What is persistent communication? Answer: messages stored until received (survives receiver downtime).
- Contrast RPC vs message-oriented coupling. Answer: RPC is tight (direct request/reply); message-oriented is loose (via queue/topic).
4.4 Multicast Communication
Plain-language definition and why it matters. Multicast sends one message from one sender to a group of recipients efficiently. It matters for service discovery, streaming, and group coordination where many receivers need the same data.
Core theory. IP multicast: sender addresses a class D group address (224.0.0.0–239.255.255.255); routers replicate packets only to interested subnets; receivers join via IGMP. Unicast = one-to-one; broadcast = one-to-all on a subnet; multicast = one-to-many (interested). Multicast is unreliable (no ACK by default) and not supported across the public Internet widely; application-layer multicast/overlay exists. Use cases: service discovery, stock ticks, video streaming, group chat.
Syntax / notation. Class D range example: 224.0.1.1; IGMP join group.
Worked example. A stock ticker server multicasts price updates to group 224.0.1.1; clients join the group and receive all ticks; no per-client copy from server.
Realistic use case. Service discovery: a new server multicasts an announcement; interested clients discover it without a central directory.
Comparison table.
| Type | Sender(s) | Receiver(s) | Scope |
|---|---|---|---|
| Unicast | one | one | point-to-point |
| Broadcast | one | all on subnet | local network |
| Multicast | one | group members | routed/limited |
Swipe to see all columns
Common mistakes / limitations. Assuming multicast works over the open Internet (often blocked); treating multicast as reliable (it's not; need application-level repair); confusing broadcast (all) with multicast (group only).
Exam-ready answer points. Define multicast; explain class D addresses and IGMP; contrast unicast/broadcast/multicast; list use cases; note unreliability and Internet limitations.
Self-check questions with answers.
- What is the IP multicast address range? Answer: Class D, 224.0.0.0–239.255.255.255.
- Contrast broadcast vs multicast. Answer: broadcast goes to all on a subnet; multicast goes only to group members.
4.5 Case Study: Java RMI and Message Passing Interface (MN)
Plain-language definition and why it matters. Java RMI is Java's remote invocation (object-oriented RPC) and MPI is a standard for message passing in parallel/distributed computing. Studying both contrasts object-based remote calls with explicit message passing.
Core theory. Java RMI: remote object implements a remote interface (extends java.rmi.Remote, methods throw RemoteException); java.rmi.Naming/LocateRegistry to register/lookup; rmic historically generated stubs/skeletons; stub on client, skeleton on server; RMI uses Java object serialization for marshalling; RMI registry (port 1099) for binding names. MPI: Message Passing Interface library for parallel programs (processes with ranks); MPI_Send, MPI_Recv, MPI_Init, MPI_Comm_rank, MPI_Comm_size; point-to-point and collective operations (broadcast, reduce, scatter, gather); SPMD model. Note "(MN)" in source likely refers to MPI.
Syntax / notation. RMI: Naming.rebind("rmi://host/obj", obj), Naming.lookup("rmi://host/obj"). MPI: MPI_Send(&buf, count, type, dest, tag, comm).
Worked example. RMI: server registers Calculator remote; client looks it up and calls add(2,3) remotely, getting 5. MPI: rank 0 sends an array to rank 1 via MPI_Send; rank 1 receives via MPI_Recv and computes a sum.
Realistic use case. A Java enterprise app uses RMI to let app servers call remote EJB-like services; a scientific cluster uses MPI to distribute a simulation across nodes.
Comparison table.
| Java RMI | MPI | |
|---|---|---|
| Model | remote object method call | explicit message send/receive |
| Binding | registry lookup | ranks + communicator |
| Marshalling | Java serialization | explicit buffers |
| Domain | distributed Java apps | parallel/scientific computing |
Common mistakes / limitations. RMI: firewall/NAT issues, serialization security, both ends need Java; MPI: processes don't share memory (explicit messages), deadlocks from mismatched send/recv, requires MPI implementation (OpenMPI/MPICH).
Exam-ready answer points. Describe Java RMI (remote interface, registry, stub/skeleton, serialization); describe MPI (ranks, Send/Recv, collectives); contrast them.
Self-check questions with answers.
- What does the RMI registry do? Answer: binds/lookup remote object names (like a directory).
- Name two MPI functions. Answer: MPI_Send and MPI_Recv (also MPI_Init, MPI_Comm_rank).
Key terms — Unit 4
socket · IP address · port · TCP · UDP · stream · datagram · marshalling · unmarshalling · endianness · partial failure · RPC · client stub · server stub · port mapper · idempotent · at-least-once · at-most-once · exactly-once · message-oriented · mailbox · persistent · transient · point-to-point · publish/subscribe · multicast · class D · IGMP · unicast · broadcast · Java RMI · Remote · RemoteException · registry · serialization · stub · skeleton · MPI · rank · MPI_Send · MPI_Recv · collective · SPMD
Unit summary — Unit 4
Communication rests on sockets (TCP reliable/ordered, UDP fast/unreliable), ports, marshalling/endianness, and partial failure. RPC hides message passing behind stubs and marshalling (at-least/at-most/exactly-once; idempotency). Message-oriented communication uses mailboxes/queues (persistent/transient; point-to-point/pub/sub) for loose coupling. Multicast (Class D, IGMP) one-to-many. Java RMI (object-based remote calls) vs MPI (explicit rank-based message passing).
Unit 5: Naming
Teaching hours: 5
Topics in outline order
- 5.1 Name Identifiers, and Addresses
- 5.2 Structured Naming
- 5.3 Attribute-based naming
- 5.4 Case Study: The Global Name Service
5.1 Name Identifiers, and Addresses
Plain-language definition and why it matters. Names, identifiers, and addresses are different ways to refer to entities. Understanding the difference matters because systems resolve human-friendly names to machine addresses (e.g., DNS maps a name to an IP address).
Core theory. Name: human-readable, location-independent (e.g., www.example.edu). Identifier: unique, often immutable, used internally (e.g., a UUID, object reference, inode). Address: network location where an entity can be reached (e.g., IP address 203.0.113.10, MAC address). Mapping/name resolution converts name → identifier → address. Names may change address (host moves) but identifier stays fixed.
Syntax / notation. Address example: IPv4 203.0.113.10:80 (IP + port); identifier: UUID 550e8400-e29b-41d4-a716-446655440000.
Worked example. User types www.example.edu: DNS resolves the name to IP 203.0.113.10 (address); the browser opens a socket to that address. Internally the resource may have an identifier (URL path + resource ID).
Realistic use case. A file server exports files by file handle (identifier) while users access by path (name); the server resolves path → file handle → disk address.
Comparison table.
| Example | Mutable? | Purpose | |
|---|---|---|---|
| Name | www.example.edu | yes (can be renamed) | human-friendly reference |
| Identifier | UUID / object ref | no (fixed) | unique, stable identity |
| Address | 203.0.113.10:80 | yes (can move) | where to reach it |
Swipe to see all columns
Common mistakes / limitations. Treating name, identifier, address as interchangeable; assuming an address is permanent (hosts move/change IP); assuming a name uniquely identifies forever (names can be reused).
Exam-ready answer points. Define name/identifier/address with examples; explain name resolution; state which is mutable vs immutable.
Self-check questions with answers.
- Which is location-independent? Answer: name (and identifier); address is location-dependent.
- Give an example of an address. Answer: IP address + port (e.g., 203.0.113.10:80).
5.2 Structured Naming
Plain-language definition and why it matters. Structured naming organizes names in a hierarchy (like a tree or directory) so names can be partitioned and resolved efficiently. It matters because flat names don't scale; hierarchy enables delegation and local resolution (DNS domain hierarchy, file system paths, X.500 LDAP).
Core theory. Name space as a tree: root → top-level domains → domains → hosts. Each node has a name; a fully qualified name is the path from root (e.g., www.example.edu.). Resolution traverses the tree, possibly delegating to sub-servers (DNS delegation). Administrative partitioning lets different orgs manage subtrees. Examples: DNS domain hierarchy, file-system pathnames (/home/user/file), LDAP/X.500 directory entries (cn=user,dc=example,dc=edu).
Syntax / notation. DNS FQDN: www.example.edu. (trailing dot = root). LDAP DN: cn=Alice,ou=staff,dc=example,dc=edu.
Worked example. Resolving www.example.edu: resolver asks root → .edu TLD server → example.edu authoritative → IP. Delegation: example.edu admin manages its own subtree.
Realistic use case. A university uses LDAP structured naming (dc=university,dc=edu.np) to organize users, courses, and rooms.
Comparison table.
| Structured name | Example | Hierarchy levels |
|---|---|---|
| DNS domain name | www.example.edu. | root, edu, example, www |
| File path | /home/alice/docs/a.txt | /, home, alice, docs, a.txt |
| LDAP DN | cn=alice,dc=edu,dc=np | root, dc, ou, cn |
Common mistakes / limitations. Forgetting the root (trailing dot in FQDN); assuming resolution is local only (may traverse multiple servers); confusing relative vs fully qualified names.
Exam-ready answer points. Explain structured naming as a tree; name resolution via delegation/traversal; give DNS and file path examples; explain FQDN.
Self-check questions with answers.
- What is a fully qualified domain name? Answer: a complete domain name from the host to the root (e.g., www.example.edu.).
- Name one structured naming system besides DNS. Answer: file-system paths or LDAP/X.500 directory.
5.3 Attribute-based naming
Plain-language definition and why it matters. Attribute-based naming finds entities by describing their attributes (e.g., "a color printer on the third floor") rather than a fixed name. It matters for discovery and lookup where the caller knows properties, not a name.
Core theory. Entities have attribute-value pairs (e.g., type=printer, color=true, location=floor3). A query matches attributes to find entities (e.g., "all color printers"). Used in directory services, service discovery (SDLP, mDNS/DNS-SD), and attribute-based access/lookup. Challenges: attribute naming/schema consistency, search performance, updates when attributes change. Not a single unique name — multiple entities may match.
Syntax / notation. Query example: (type=printer)&(color=true)&(location=floor3); LDAP filter style (&(objectClass=printer)(colorPrinting=TRUE)).
Worked example. A user asks directory for "color printers on floor 3": query returns list of matching printer entities with their addresses; user picks one.
Realistic use case. mDNS/DNS-SD lets a laptop find nearby printers by attribute (_ipp._tcp.local) without knowing their names.
Comparison table.
| Name-based | Attribute-based |
|---|---|
| exact name → address | attributes → set of matches |
| unique result | possibly many results |
| needs a known name | works with properties only |
Common mistakes / limitations. Assuming attribute queries return one entity (may return many); stale attributes (entity moved but attributes not updated); no schema → inconsistent attribute values.
Exam-ready answer points. Define attribute-based naming; show attribute-value query; contrast with name-based; list uses (directory, service discovery); name challenges.
Self-check questions with answers.
- How does attribute-based naming differ from name-based naming? Answer: it matches attributes and may return many entities, not one exact name.
- Name one use of attribute-based naming. Answer: service/directory discovery (e.g., find color printers).
5.4 Case Study: The Global Name Service
Plain-language definition and why it matters. The Global Name Service (GNS) concept is a worldwide, scalable naming infrastructure mapping names to entities/addresses (DNS is the practical realization). It matters because global naming underlies the Internet and distributed systems.
Core theory. Goals: unique names, scalable, decentralized administration, location independence (name stays valid if entity moves). DNS as GNS: hierarchical, distributed database; root servers, TLD servers, authoritative servers; caching at resolvers; iterative vs recursive queries; resource records (A = name→IP, MX = mail, CNAME = alias, NS = name server). GNS must handle name collisions (admin partitions), updates (dynamic DNS), and security (DNSSEC) — introduced briefly as concerns.
Syntax / notation. DNS resource record format: name TTL class type data, e.g., www.example.edu. IN A 203.0.113.10.
Worked example. Recursive query for www.example.edu: local resolver queries root → .edu → example.edu → returns IP; caches result at each level for TTL duration.
Realistic use case. Every website/email relies on DNS as the global name service; without it, users would remember IP addresses.
Comparison table.
| Record type | Meaning | Example data |
|---|---|---|
| A | name → IPv4 | 203.0.113.10 |
| AAAA | name → IPv6 | 2001:db8::1 |
| MX | mail server for domain | mail.example.edu |
| CNAME | alias → canonical name | www → example.edu |
| NS | authoritative name server | ns1.example.edu |
Common mistakes / limitations. Assuming DNS is one database (it's distributed and cached); ignoring TTL (caching delays propagation of changes); confusing recursive vs iterative queries.
Exam-ready answer points. Explain GNS goals; describe DNS as GNS (hierarchy, servers, caching); list resource record types; explain recursive vs iterative; note DNSSEC/security briefly.
Self-check questions with answers.
- Which DNS record maps a name to an IPv4 address? Answer: A record.
- What is the purpose of TTL in DNS? Answer: how long a resolver caches a record before re-querying.
Key terms — Unit 5
name · identifier · address · name resolution · structured naming · name space · tree · delegation · fully qualified domain name · LDAP · DN · attribute-based naming · attribute-value · query · service discovery · Global Name Service · DNS · root server · TLD · authoritative server · resource record · A · AAAA · MX · CNAME · NS · TTL · recursive · iterative · DNSSEC
Unit summary — Unit 5
Names are human-friendly, identifiers are stable unique IDs, and addresses are reachable locations; name resolution maps name → identifier → address. Structured naming uses a hierarchical tree (DNS, file paths, LDAP) with delegation. Attribute-based naming finds entities by properties and may return many results. The Global Name Service is realized by DNS (hierarchical, distributed, cached; record types A/AAAA/MX/CNAME/NS; TTL).
Unit 6: Coordination
Teaching hours: 7
Topics in outline order
- 6.1 Clock Synchronization
- 6.2 Logical Clocks
- 6.3 Mutual Exclusion
- 6.4 Election Algorithm
- 6.5 Location System
- 6.6 Distributed Event Matching
- 6.7 Gossip-based coordination
6.1 Clock Synchronization
Plain-language definition and why it matters. Clock synchronization keeps clocks on different machines approximately consistent. It matters because distributed systems use timestamps to order events, but machine clocks drift and there is no perfect global clock.
Core theory. Physical clocks drift (crystal oscillator differences); UTC is the reference (via GPS/atomic clocks). Cristian's algorithm: client asks time server, adjusts for round-trip delay ((t1+t2)/2 offset). Berkeley algorithm: time daemon averages all clocks and tells each how to adjust (good when no external UTC). Network Time Protocol (NTP): hierarchical strata (stratum 0 = atomic/GPS, stratum 1 = NTP server, etc.), clients sync to servers. Logical vs physical clocks distinction. Accuracy vs precision.
Syntax / notation. Cristian's offset formula: offset = ((t2 - t1) - (t2 - t1)) / 2? Correct: client sends at t0, server returns its time T at client receive t1; estimated server time at client = T + (t1-t0)/2; adjust client clock accordingly.
Worked example. Cristian's: client sends request at t0=100, server replies "T=200" arriving at client t1=110. Round trip = 10, one-way ≈ 5. Server time at arrival ≈ 205; client sets clock to ~205 (±5 accuracy).
Realistic use case. Financial transaction logs across datacenters need NTP-synced clocks to order events correctly.
Comparison table.
| Method | Reference | Best for |
|---|---|---|
| Cristian's | one time server | simple client-server |
| Berkeley | average of all machines | no external UTC source |
| NTP | stratum hierarchy (GPS/atomic) | Internet-scale sync |
Common mistakes / limitations. Assuming all machines agree on "now" without sync; ignoring network delay asymmetry in Cristian's; setting clocks backward (causes event ordering problems — use logical clocks or monotonic clocks).
Exam-ready answer points. Explain why clocks drift; describe Cristian's, Berkeley, NTP; explain strata; contrast physical vs logical clocks.
Self-check questions with answers.
- What is clock drift? Answer: a clock gains/loses time relative to true time because its oscillator is imperfect.
- Name one clock-synchronization algorithm. Answer: Cristian's / Berkeley / NTP.
6.2 Logical Clocks
Plain-language definition and why it matters. Logical clocks order events without physical time, using counters. They matter because physical clocks cannot perfectly order concurrent events across machines.
Core theory. Lamport timestamps: each process has a counter; on local event increment; on send, counter++ and attach timestamp; on receive, counter = max(local, received) + 1. Rule: if a → b (happened-before) then L(a) < L(b), but L(a) < L(b) does NOT imply a → b (concurrent possible). Vector clocks: each process keeps a vector of counters (one per process); on send attach vector; on receive take element-wise max + increment own. Vector clocks can detect concurrency (neither vector ≤ the other). Happened-before relation: (1) same process order, (2) send before receive, (3) transitivity; events not related by → are concurrent.
Syntax / notation. Lamport: L as integer. Vector: V[i] per process i; V = V' means equal; V ≤ V' element-wise; concurrent if V ≰ V' and V' ≰ V.
Worked example. Lamport: P1 event e1 (L=1), sends m (L=2) to P2. P2 receives m: L2 = max(0,2)+1=3. So e1 (L=1) → receive (L=3). Two events with same timestamp but on different processes may be concurrent (cannot tell order).
Realistic use case. A distributed key-value store uses vector clocks to detect conflicting writes (concurrent updates to the same key) and resolve them.
Comparison table.
| Lamport clock | Vector clock | |
|---|---|---|
| Size | one integer | vector (one entry/process) |
| Total order | yes (partial → total with PID tiebreak) | no |
| Detect concurrency | no | yes |
| Causality | captures → | captures → and concurrency |
Common mistakes / limitations. Assuming Lamport timestamps give real-time order (they don't); equal vector clocks mean identical causal history; concurrent events cannot be ordered by logical clocks alone.
Exam-ready answer points. Explain Lamport and vector clock algorithms; happened-before relation; contrast total vs partial order and concurrency detection.
Self-check questions with answers.
- What does vector clock detect that Lamport cannot? Answer: concurrency (whether events are causally unrelated).
- Define happened-before (→) briefly. Answer: same-process order, send-before-receive, and transitivity; unrelated = concurrent.
6.3 Mutual Exclusion
Plain-language definition and why it matters. Distributed mutual exclusion ensures only one process accesses a shared resource at a time across machines. It matters to prevent conflicts (e.g., two nodes editing the same file).
Core theory. Centralized algorithm: one coordinator grants tokens/requests (simple, single point of failure). Distributed algorithm: process multicast request to all, collects replies, enters when it has replies from all (Ricart–Agrawala uses timestamps to prioritize and reduce messages). Token ring: a token circulates; holder enters critical section (fair, no starvation, token loss problem). Requirements: mutual exclusion (one at a time), freedom from deadlock, freedom from starvation, fairness. Performance measured by messages per critical section entry and synchronization delay.
Syntax / notation. Pseudocode: on request, send REQUEST(timestamp, id) to all; on receive, reply if not requesting or if requester has higher priority; enter critical section after N-1 replies.
Worked example. Ricart–Agrawala with 3 processes: P1 timestamps request 5, P2 timestamps 7. P1's request has priority (lower timestamp). P1 enters CS after getting replies from P2 and P3.
Realistic use case. A distributed database uses mutual exclusion so only one node updates a given row at a time.
Comparison table.
| Algorithm | Coordinator? | Messages per entry | Weakness |
|---|---|---|---|
| Centralized | yes | 3 | single point of failure |
| Distributed (Ricart–Agrawala) | no | 2(N-1) | all processes involved |
| Token ring | no (token) | variable | token loss |
Swipe to see all columns
Common mistakes / limitations. Centralized = SPOF and bottleneck; token ring token loss stalls the system; ignoring fairness/starvation.
Exam-ready answer points. State requirements (mutual exclusion, no deadlock, no starvation, fairness); describe centralized, Ricart–Agrawala, token ring; compare message costs and weaknesses.
Self-check questions with answers.
- Name three mutual exclusion requirements. Answer: mutual exclusion, freedom from deadlock, freedom from starvation (fairness optional).
- Which algorithm uses timestamps to order requests? Answer: Ricart–Agrawala (distributed).
6.4 Election Algorithm
Plain-language definition and why it matters. Election algorithms choose a coordinator/leader among processes. They matter because after the coordinator fails, a new leader must be elected (e.g., in mutual exclusion or primary-backup replication).
Core theory. Assumptions: unique process IDs, processes know each other (or can discover), one election at a time. Bully algorithm: highest-ID process wins; on failure detection, a process holds election, sends Election to higher IDs; if no answer, it wins and announces Coordinator message. Ring algorithm: processes arranged in logical ring; election message circulates with IDs; highest ID becomes coordinator and message returns. Comparison: bully needs all-to-all (or higher-ID) messages; ring needs O(N) messages per election but assumes ring structure.
Syntax / notation. Bully pseudocode: Election(i): send Election to all j>i; if no reply, becomeCoordinator(), send Coordinator to all.
Worked example. Bully with processes P1..P5, P5 (coordinator) fails. P1 detects, sends Election to P2..P5. P2..P4 answer and start their own elections; P5 dead. P4 gets no answer from P5, becomes coordinator, announces Coordinator(P4).
Realistic use case. A primary-backup system elects a new primary when the old primary crashes.
Comparison table.
| Algorithm | Structure | Messages | Assumption |
|---|---|---|---|
| Bully | any | O(N²) worst | unique IDs, know higher IDs |
| Ring | logical ring | O(N) | ring order known |
Swipe to see all columns
Common mistakes / limitations. Multiple concurrent elections causing split decisions; network partitions electing two leaders (need fencing/epoch); assuming election is instant.
Exam-ready answer points. Explain purpose of election; describe Bully and Ring; contrast message costs and assumptions.
Self-check questions with answers.
- What does the Bully algorithm use to pick a coordinator? Answer: the highest process ID.
- Name one election algorithm. Answer: Bully algorithm (or Ring algorithm).
6.5 Location System
Plain-language definition and why it matters. A location system finds where an entity (object, service, mobile user) is currently located so it can be accessed. It matters in mobile and distributed systems where entities move and addresses change.
Core theory. Location vs address: location = current access point; address may be permanent. Location service: entities register location; clients query. Scalability approaches: hierarchical location servers, home/location server (like mobile IP home agent), caching, forwarding pointers. Mobile IP: home network, foreign network, home agent, care-of address, registration, triangular routing (optimized via binding update). Tracking mobility: location updates when entity moves.
Syntax / notation. Care-of address (CoA): the address of the entity on the foreign network.
Worked example. Mobile IP: user's laptop (home network A) roams to network B, gets care-of address in B, registers with home agent in A; packets to home address are forwarded to CoA.
Realistic use case. Find-my-phone or ride-hailing apps locate the driver's phone and send the location to the rider's app.
Comparison table.
| Approach | Mechanism | Scale |
|---|---|---|
| Centralized location server | one directory | small |
| Hierarchical | servers by region/domain | large |
| Home/foreign agent | Mobile IP care-of address | mobile hosts |
| Caching | cache recent locations | reduces lookups |
Common mistakes / limitations. Stale location (entity moved but not updated); triangular routing inefficiency (solve with binding update/route optimization); single location server = bottleneck/SPOF.
Exam-ready answer points. Explain location vs address; describe location service, home/foreign agent, care-of address, caching; contrast scalability approaches.
Self-check questions with answers.
- What is a care-of address? Answer: the current address of a mobile node on a foreign network.
- Name one scalability approach for location systems. Answer: hierarchical location servers (or caching).
6.6 Distributed Event Matching
Plain-language definition and why it matters. Distributed event matching routes events to subscribers whose interests match the event content. It matters for publish/subscribe systems where many consumers react to events without knowing publishers.
Core theory. Content-based publish/subscribe: publishers publish events with attributes; subscribers register subscriptions (filters/queries); the middleware matches events to subscriptions and delivers. Matching can be topic-based (subject/channel) or content-based (attribute predicates). Challenges: matching efficiency (many subscriptions, complex predicates), scalability, filtering at brokers vs endpoints, guaranteed delivery. Examples: stock alerts (price > threshold), news by category.
Syntax / notation. Subscription example: stock = "NPR" AND price > 100; event: {stock:"NPR", price:110} matches.
Worked example. A news service: subscribers register category=sports; publisher posts an event with category=sports; the broker delivers it to all matching subscribers; a category=politics subscriber does not get it.
Realistic use case. An IoT platform: sensors publish temperature events; subscribers with location=kathmandu AND temp > 30 get alerts.
Comparison table.
| Topic-based | Content-based | |
|---|---|---|
| Match on | subject/channel name | event attribute values |
| Expressiveness | low | high |
| Filtering | easy | more complex |
Common mistakes / limitations. Assuming all subscribers get every event (only matching ones do); complex content-based matching is expensive at scale; unreliable delivery unless persistence/acks used.
Exam-ready answer points. Define distributed event matching; contrast topic-based vs content-based; explain publisher/subscriber/broker roles; list challenges.
Self-check questions with answers.
- What is content-based publish/subscribe? Answer: matching events to subscriptions by event attribute values.
- Contrast topic vs content based. Answer: topic matches by channel; content matches by attribute predicates.
6.7 Gossip-based coordination
Plain-language definition and why it matters. Gossip (epidemic/probabilistic) coordination spreads information through random peer-to-peer exchanges. It matters for scalable, fault-tolerant dissemination (membership, failure detection, aggregation) without a central coordinator.
Core theory. Nodes periodically pick a random peer and exchange state (rumor mongering). Information spreads epidemically. Used for: failure detection (suspect list), membership (who's alive), aggregation (compute average/count), and eventual consistency (anti-entropy repair). Properties: eventual delivery with high probability, no single point of failure, scalable, but eventual (not immediate) consistency and possible duplicate messages. Tunable: fanout (how many peers), gossip period.
Syntax / notation. Pseudocode: every T seconds, peer = randomMember(); exchangeState(peer).
Worked example. 100-node cluster: node A learns node D failed, tells 3 random peers in next round, they tell others; within ~log(100) rounds nearly all nodes know D is down.
Realistic use case. Apache Cassandra uses gossip for cluster membership and failure detection across nodes.
Comparison table.
| Gossip | Centralized coordinator |
|---|---|
| no SPOF | SPOF |
| eventual consistency | immediate |
| scales well | bottleneck at scale |
| redundant traffic | minimal traffic |
Common mistakes / limitations. Assuming immediate consistency (gossip is eventual); network partitions delay dissemination; tuning fanout/period trades speed vs traffic.
Exam-ready answer points. Explain gossip mechanism (random peer exchange, epidemic spread); list uses (failure detection, membership, aggregation, anti-entropy); state properties and trade-offs.
Self-check questions with answers.
- How does gossip spread information? Answer: nodes periodically exchange state with random peers (epidemic/randomized).
- Name one use of gossip. Answer: failure detection / cluster membership (or aggregation, anti-entropy).
Key terms — Unit 6
clock drift · Cristian's · Berkeley · NTP · stratum · Lamport timestamp · vector clock · happened-before · concurrent · mutual exclusion · centralized · Ricart–Agrawala · token ring · election · Bully · Ring algorithm · location · address · care-of address · home agent · foreign agent · Mobile IP · publish/subscribe · topic-based · content-based · gossip · epidemic · fanout · failure detection · anti-entropy
Unit summary — Unit 6
Clock synchronization (Cristian's, Berkeley, NTP) handles physical clock drift; logical clocks (Lamport, vector) order events causally without physical time and vector clocks detect concurrency. Mutual exclusion (centralized, Ricart–Agrawala, token ring) serializes shared-resource access. Election algorithms (Bully, Ring) pick a coordinator. Location systems (home/foreign agent, care-of address, caching) find mobile entities. Distributed event matching routes events to matching subscribers (topic vs content-based). Gossip coordination disseminates state epidemically for failure detection and membership.
Unit 7: Consistency and Replication
Teaching hours: 5
Topics in outline order
- 7.1 Introduction
- 7.2 Data-centric consistency models
- 7.3 Client-centric consistency models
- 7.4 Replica management
- 7.5 Consistency protocols
- 7.6 Caching and Replication in Web
7.1 Introduction
Plain-language definition and why it matters. Replication keeps copies of data on multiple nodes; consistency defines how up-to-date those copies appear. They matter for availability, performance (local reads), and fault tolerance — but replicas can diverge, so consistency models define the rules.
Core theory. Replica = copy of data. Reasons to replicate: availability (if one fails, others serve), performance (read near user), fault tolerance. Problems: replicas diverge (update inconsistency), write propagation cost, consistency vs latency/availability trade-off (CAP/PACELC intuition). Data-centric models focus on the data store's guarantees; client-centric focus on what a single client observes.
Syntax / notation. Conceptual; version vectors example: [A:3, B:1] tracks version per replica.
Worked example. Two replicas of a bank balance: ATM in Kathmandu updates replica A; ATM in Pokhara updates replica B; without coordination, the balances diverge until updates propagate.
Realistic use case. DNS replicates zone records globally so users resolve names from a nearby server.
Comparison table.
| Goal | Benefit | Cost/Risk |
|---|---|---|
| Availability | survive node failure | more nodes to manage |
| Performance | local/near reads | write propagation latency |
| Fault tolerance | data survives loss | consistency divergence |
Common mistakes / limitations. Assuming replication is free (writes must propagate); assuming strong consistency with high availability under partitions (CAP trade-off).
Exam-ready answer points. Define replication and consistency; list reasons to replicate and problems introduced; mention consistency vs availability trade-off.
Self-check questions with answers.
- Name two reasons to replicate data. Answer: availability and performance (fault tolerance also valid).
- What problem does replication introduce? Answer: replicas can diverge (inconsistent copies).
7.2 Data-centric consistency models
Plain-language definition and why it matters. Data-centric models specify guarantees the data store gives about when reads see writes. They matter because they define the programming contract for replicated data.
Core theory. Models: strict consistency (absolute real-time order — impractical), linearizability/atomic consistency (every operation appears instantaneously at some point between invocation and response — strong), sequential consistency (all processes see same order of operations, respects per-process program order), causal consistency (causally related operations seen in order by all; concurrent may differ), eventual consistency (if no new updates, all replicas eventually converge — weak). FIFO, PRAM, weak consistency variants. Strong models are easier to program but cost latency/availability; weak models perform better but require application to handle anomalies.
Syntax / notation. Conceptual; happens-before order for causal consistency.
Worked example. Eventual consistency: user edits a profile on replica A; a friend reading replica B seconds ago sees the old value, but after propagation both show the new value (no new writes → converge).
Realistic use case. A shopping cart uses eventual consistency (add-to-cart may briefly show differently on two devices) but payment uses linearizable consistency.
Comparison table.
| Model | Guarantee | Strength | Cost |
|---|---|---|---|
| Strict/Linearizable | real-time instant order | strong | high latency/availability cost |
| Sequential | same order everywhere | strong | high |
| Causal | causal order preserved | medium | moderate |
| Eventual | converge if no writes | weak | low cost, high availability |
Swipe to see all columns
Common mistakes / limitations. Confusing sequential with linearizable (sequential doesn't require real-time); assuming eventual consistency means immediate (it doesn't); picking weak consistency for financial transactions (risky).
Exam-ready answer points. List data-centric models from strict to eventual; define linearizability, sequential, causal, eventual; explain trade-offs.
Self-check questions with answers.
- What does eventual consistency guarantee? Answer: if no new updates, replicas eventually converge.
- Which model is strongest? Answer: strict/linearizable consistency.
7.3 Client-centric consistency models
Plain-language definition and why it matters. Client-centric models describe consistency from a single client's view across replicas (which may differ at different times). They matter for mobile/weakly connected clients that talk to different replicas.
Core theory. Guarantees: read-your-writes (client always sees its own updates), monotonic reads (client never sees older data after seeing newer), monotonic writes (client's writes are serialized), writes-follow-reads (a write after a read happens after that read), session consistency (combines these within a session). Unlike data-centric, these bind to a client/session, not the store globally. Useful when a client sticks to one replica within a session ("sticky" sessions).
Syntax / notation. Conceptual; session = sequence of operations by one client.
Worked example. Read-your-writes: a user edits their display name; immediately refreshing shows the new name (even if other clients still see old). Monotonic reads: once the user sees v2, refreshing won't show v1 again.
Realistic use case. A mobile user on spotty network sticks to one replica for a session; session consistency keeps their view sane.
Comparison table.
| Guarantee | Meaning |
|---|---|
| Read-your-writes | see own updates |
| Monotonic reads | never go backward in time |
| Monotonic writes | own writes serialized |
| Writes-follow-reads | write ordered after a prior read |
Common mistakes / limitations. Client-centric guarantees don't hold across different clients; session guarantees end when the session/routing changes.
Exam-ready answer points. Define client-centric consistency; list the four/five guarantees; contrast with data-centric (client/session vs global store).
Self-check questions with answers.
- What is read-your-writes consistency? Answer: a client always sees its own previous updates.
- How does client-centric differ from data-centric consistency? Answer: client-centric is per-client/session; data-centric is a global store guarantee.
7.4 Replica management
Plain-language definition and why it matters. Replica management decides where replicas are placed, how updates propagate, and how replicas are added/removed. It matters because placement affects latency and cost; update propagation affects consistency.
Core theory. Placement: where to put replicas (near users, near data, based on access). Update propagation: eager (push updates immediately to all — strong but slow) vs lazy (propagate later — fast writes, temporary inconsistency). Replica types: primary/backup (primary handles writes) vs update-anywhere (any replica accepts writes — needs conflict resolution). Replica addition/removal and state transfer. Leases and versioning for replica control.
Syntax / notation. Conceptual; eager: write → update all replicas → acknowledge; lazy: write → primary acknowledges → propagate asynchronously.
Worked example. Eager: write to primary waits until all backups confirm (client sees consistent data but waits). Lazy: write confirmed at primary; backups update in background (client gets fast response, may read stale briefly).
Realistic use case. A CDN eagerly pushes new content to edge nodes before a launch; a lazy system updates caches in background.
Comparison table.
| Eager propagation | Lazy propagation | |
|---|---|---|
| Consistency | strong | eventual/temporary stale |
| Write latency | high | low |
| Availability during writes | lower | higher |
Common mistakes / limitations. Update-anywhere without conflict resolution → diverging replicas; eager propagation over WAN → high latency; ignoring replica placement (users far from their replica).
Exam-ready answer points. Explain replica management: placement, update propagation (eager vs lazy), primary/backup vs update-anywhere; state trade-offs.
Self-check questions with answers.
- Contrast eager vs lazy update propagation. Answer: eager updates all replicas before acknowledging (strong, slow); lazy acknowledges early and propagates later (fast, possibly stale).
- Name one replica placement consideration. Answer: place replicas near users to reduce read latency.
7.5 Consistency protocols
Plain-language definition and why it matters. Consistency protocols implement the rules that keep replicas consistent. They matter because they are the mechanism turning a consistency model into behavior.
Core theory. Protocols for continuous consistency: primary-based (primary sequences writes, backups apply), replicated writing (update-anywhere with conflict resolution), cache coherence (hardware/DSM-style). For quorum: read quorum (Nr) + write quorum (Nw) with Nr + Nw > N guarantees read-after-write consistency (majority voting). Number of replicas N; read needs Nr acknowledgments, write needs Nw. Examples: primary-backup, quorum consensus, two-phase commit-like replication. Trade-offs: quorum size vs availability vs consistency.
Syntax / notation. Quorum condition: Nr + Nw > N (strict) ensures any read quorum overlaps any write quorum.
Worked example. N=5 replicas, Nw=3, Nr=3. A write succeeds after 3 acks; a read contacts 3 and gets at least one replica with the latest write (3+3>5 → overlap ≥1).
Realistic use case. A distributed key-value store uses quorum reads/writes so reads see recent writes while tolerating 2-node failures.
Comparison table.
| Protocol | Approach | Strength |
|---|---|---|
| Primary-based | one primary orders writes | simple, strong |
| Replicated writing | any replica accepts writes | available, needs conflict resolution |
| Quorum | Nr + Nw > N | tunable consistency/availability |
Common mistakes / limitations. Choosing Nr+Nw ≤ N (reads may miss latest write); primary failure without election (need replica coordination); ignoring network partitions.
Exam-ready answer points. Describe primary-based, replicated writing, quorum; give the quorum formula and example; explain trade-offs.
Self-check questions with answers.
- What is the quorum condition for read-after-write consistency? Answer: Nr + Nw > N.
- Name one consistency protocol. Answer: primary-based replication (or quorum consensus).
7.6 Caching and Replication in Web
Plain-language definition and why it matters. Web caching/replication places copies of web content near users to reduce latency and server load. It matters because most Web traffic is cacheable and replication improves user experience.
Core theory. Caches: browser cache, proxy cache (shared), CDN edge servers. Conditional GET (ETag, Last-Modified) lets caches validate freshness without re-downloading. Cache-Control headers (max-age, public, private, no-cache). Replication: content copied to origin + edge servers; request routing sends user to nearest edge (anycast/GeoDNS). Invalidation/purge when content changes. Web consistency is weak (caches may serve stale) — controlled by TTL/validation.
Syntax / notation. HTTP: Cache-Control: max-age=3600; ETag: "abc123"; conditional request If-Modified-Since: <date> / If-None-Match: "abc123".
Worked example. User requests an image: browser cache has it with max-age=3600 and not expired → served locally (no server hit). If expired, browser sends If-None-Match; server returns 304 Not Modified if unchanged (no body) or 200 with new image.
Realistic use case. A news site uses a CDN: article images cached at edge nodes near readers; when an image changes, the CDN purges the old copy.
Comparison table.
| Cache | Scope | Example |
|---|---|---|
| Browser | single user | Chrome cache |
| Proxy | many users (org/ISP) | Squid proxy |
| CDN edge | Internet edge | Cloudflare/Akamai edge |
Common mistakes / limitations. Serving stale content after an update (forgot to purge/short TTL); caching personalized/private content in a shared proxy (privacy bug); ignoring conditional GET (wastes bandwidth).
Exam-ready answer points. Explain web caching (browser/proxy/CDN), conditional GET/ETag, Cache-Control, replication to edge, invalidation; note weak consistency.
Self-check questions with answers.
- What does ETag do? Answer: validator for conditional GET to check if cached content changed.
- Name three web cache locations. Answer: browser, proxy, CDN edge.
Key terms — Unit 7
replica · replication · availability · consistency · strict · linearizable · sequential · causal · eventual · data-centric · client-centric · read-your-writes · monotonic reads · monotonic writes · writes-follow-reads · session · replica placement · eager · lazy · primary/backup · update-anywhere · quorum · Nr · Nw · N · primary-based · replicated writing · cache · proxy · CDN · ETag · Cache-Control · conditional GET · invalidation
Unit summary — Unit 7
Replication improves availability, performance, and fault tolerance but risks diverging copies; consistency models define the rules. Data-centric models range from strict/linearizable (strong) to eventual (weak). Client-centric models (read-your-writes, monotonic reads/writes, writes-follow-reads, session) bound a single client's view. Replica management covers placement and eager vs lazy propagation; primary/backup vs update-anywhere. Consistency protocols include primary-based and quorum (Nr + Nw > N). Web caching/replication uses browser/proxy/CDN caches, ETag/Cache-Control conditional GET, and invalidation.
Unit 8: Fault Tolerance
Teaching hours: 5
Topics in outline order
- 8.1 Introduction to fault tolerance
- 8.2 Process resilience
- 8.3 Reliable client-server communication
- 8.4 Reliable group communication
- 8.5 Distributed commit
- 8.6 Recovery
8.1 Introduction to fault tolerance
Plain-language definition and why it matters. Fault tolerance is the ability of a system to continue operating correctly when components fail. It matters because in distributed systems, failures (nodes, network, disks) are normal, not exceptional.
Core theory. Failure types: crash (stop responding), omission (fail to send/receive), timing (respond too early/late), response (wrong value), Byzantine (arbitrary/malicious behavior). Fault model: fail-stop, crash-recovery, omission, Byzantine. Dependability attributes: availability, reliability, safety, maintainability. Redundancy (hardware, information, time) masks faults. Detection (heartbeats, timeouts), masking (redundancy/retry), recovery (rollback/restart). Single point of failure (SPOF) is the enemy.
Syntax / notation. Conceptual; heartbeat interval/timeout example: ping every 5s, suspect after 15s no reply.
Worked example. A service with 3 replicas tolerates 1 crash (majority 2 available); if all 3 crash, service is down. Heartbeats detect a crashed node so traffic is routed elsewhere.
Realistic use case. An ATM network tolerates a branch server failure by routing transactions to another data center.
Comparison table.
| Failure type | Behavior |
|---|---|
| Crash | process stops, no response |
| Omission | message not sent/received |
| Timing | response outside expected time |
| Response | incorrect response |
| Byzantine | arbitrary/wrong/malicious |
Common mistakes / limitations. Designing for no failures (unrealistic); ignoring Byzantine faults when they matter (security); assuming redundancy alone guarantees tolerance (need detection + recovery too).
Exam-ready answer points. Define fault tolerance; list failure types; list dependability attributes; explain detection/masking/recovery; name SPOF.
Self-check questions with answers.
- Name three failure types. Answer: crash, omission, timing (response/Byzantine also valid).
- What is a SPOF? Answer: a component whose failure brings down the whole system.
8.2 Process resilience
Plain-language definition and why it matters. Process resilience keeps processes working despite crashes by restarting, checkpointing, and replicating state. It matters because a crashed process should not take down the service.
Core theory. Process resilience techniques: redundancy (active/replica processes), checkpointing (save state periodically to stable storage), recovery (restart from checkpoint), rollback-recovery (undo to last consistent state), message logging (log sent/received messages to rebuild state), process pairs (primary/backup). Active replication: all replicas process each request (state-machine replication). Passive replication: primary processes, backup takes over on failure.
Syntax / notation. Checkpoint example: save(state) to disk at time t; recovery loads latest checkpoint + replays logged messages.
Worked example. A transaction server checkpoints account state every minute; if it crashes at 10:07, it restarts from the 10:00 checkpoint and replays logged transactions from 10:00–10:07.
Realistic use case. A video-encoding job checkpoints progress so a node failure doesn't restart the whole job from zero.
Comparison table.
| Technique | What it does | Cost |
|---|---|---|
| Checkpointing | save state periodically | disk I/O, pause |
| Message logging | log messages for rebuild | log storage |
| Active replication | all replicas run requests | N× compute |
| Passive replication | primary + backup | failover delay |
Common mistakes / limitations. Checkpoint too often (performance hit) or too rarely (long redo); orphan messages (received but not logged) causing inconsistency on recovery.
Exam-ready answer points. Explain process resilience; describe checkpointing, message logging, rollback-recovery; contrast active vs passive replication.
Self-check questions with answers.
- What is checkpointing? Answer: saving process state to stable storage periodically so recovery can restart from it.
- Contrast active vs passive replication. Answer: active = all replicas process requests; passive = primary handles, backup takes over on failure.
8.3 Reliable client-server communication
Plain-language definition and why it matters. Reliable client-server communication ensures requests and responses are not lost despite crashes or network issues. It matters because clients depend on getting correct answers.
Core theory. Reliable RPC: client retransmits if no reply within timeout; server uses idempotent operations (safe to repeat) to handle duplicates; at-most-once semantics via request identifiers/deduplication (server remembers recent requests). ACKs, timeouts, retransmission. Handling server crash after receiving but before responding: client retries; idempotent op gives same result. Non-idempotent ops (e.g., debit account) need transactions/deduplication.
Syntax / notation. Conceptual: send(request, id); on timeout resend; server checks id in request log to discard duplicates.
Worked example. Client calls debit($10). Server receives, debits, but response lost. Client retries with same request id; server sees duplicate id, returns the earlier result without debiting again (at-most-once).
Realistic use case. A payment API uses idempotency keys so retrying a payment doesn't charge twice.
Comparison table.
| Semantics | Retry behavior | Use |
|---|---|---|
| At-least-once | retry until ack | may duplicate |
| At-most-once | deduplicate by id | may lose |
| Exactly-once | both (hard) | ideal, costly |
Common mistakes / limitations. Non-idempotent operations retried blindly → double charge; forgetting timeouts (client hangs); server crash losing unlogged state.
Exam-ready answer points. Explain reliable RPC with timeouts/retransmission; idempotency and deduplication; at-least/at-most/exactly-once; example debit.
Self-check questions with answers.
- Why is idempotency important in reliable RPC? Answer: safe to repeat after a retry (avoids duplicate effects like double debit).
- What does at-most-once semantics mean? Answer: an operation is performed zero or one time, not more (uses deduplication).
8.4 Reliable group communication
Plain-language definition and why it matters. Reliable group communication sends messages to a group so all (or all correct) members get them in a consistent order. It matters for replicated services where every replica must apply the same updates in the same order.
Core theory. Group communication properties: reliable delivery (all correct members get the message), ordering (FIFO, causal, total/atomic order — total order is strongest), agreement. Atomic broadcast/total order broadcast ensures all correct members deliver the same set of messages in the same order — foundation of state-machine replication. Group membership changes (join/leave/failure) must be agreed (view synchrony). Multicast to group with sequencing (sequencer/token).
Syntax / notation. Conceptual: atomic_broadcast(group, message) delivers to all correct members in same order.
Worked example. Three replicas use total order broadcast: client sends update; the group sequences it (message #5); all replicas apply #5 in the same order → identical state.
Realistic use case. A chat room uses reliable ordered multicast so all participants see messages in the same sequence.
Comparison table.
| Ordering | Meaning |
|---|---|
| FIFO | messages from same sender in order |
| Causal | causally related messages in order |
| Total/atomic | all members agree on one order |
Common mistakes / limitations. Total order is expensive (coordination); group membership changes mid-broadcast need agreement (view change); assuming multicast = reliable (need reliable group protocol).
Exam-ready answer points. Define reliable group communication; list ordering levels (FIFO/causal/total); explain atomic broadcast and state-machine replication; mention group membership/view.
Self-check questions with answers.
- What is total order broadcast? Answer: all correct members deliver the same messages in the same order.
- Name one ordering guarantee. Answer: FIFO / causal / total order.
8.5 Distributed commit
Plain-language definition and why it matters. Distributed commit makes a transaction atomic across multiple nodes: either all commit or all abort. It matters for distributed transactions (e.g., transferring money across accounts on different servers).
Core theory. Two-Phase Commit (2PC): coordinator asks participants to prepare (vote yes/no); if all yes, coordinator sends commit; else abort. Participants lock resources during prepare. Three-Phase Commit (3PC): adds a pre-commit phase to reduce blocking (can't fully avoid blocking without failure assumptions). Problems: blocking (coordinator failure leaves participants uncertain), single point of failure (coordinator), performance (two rounds). Not Byzantine-tolerant by default.
Syntax / notation. 2PC phases: Voting (prepare/vote) → Decision (commit/abort).
Worked example. Transfer $100 from account on node A to account on node B: coordinator tells both to prepare; both lock and vote yes; coordinator decides commit; both commit. If B votes no (insufficient funds), coordinator tells both to abort.
Realistic use case. A distributed database transfers funds atomically across two shards using 2PC.
Comparison table.
| Protocol | Phases | Blocking? | Weakness |
|---|---|---|---|
| 2PC | prepare, commit/abort | yes (coordinator fail) | coordinator SPOF, blocking |
| 3PC | canPreCommit, preCommit, commit | reduced | still can block, complex |
Swipe to see all columns
Common mistakes / limitations. 2PC blocks if coordinator fails before decision (participants hold locks); assuming 2PC handles network partitions gracefully (it doesn't); using 2PC for high-throughput (too slow).
Exam-ready answer points. Explain 2PC phases (prepare/vote, commit/abort); blocking and coordinator SPOF; mention 3PC improvement; example distributed transfer.
Self-check questions with answers.
- What are the two phases of 2PC? Answer: voting (prepare) and decision (commit/abort).
- What is the main weakness of 2PC? Answer: blocking if the coordinator fails (coordinator is a SPOF).
8.6 Recovery
Plain-language definition and why it matters. Recovery restores a system to a correct, consistent state after a failure. It matters because after a crash, data may be partially updated and must be reconciled.
Core theory. Recovery techniques: backward recovery (rollback to a checkpoint and redo), forward recovery (roll forward using logs to redo committed transactions), undo/redo logging (write-ahead logging: log before changes; undo uncommitted, redo committed), stable storage (duplicate copies), shadow paging. Recovery after media failure (restore from backup + redo log). Checkpoints reduce redo work. Two generals / consensus limits relate to agreeing after failures.
Syntax / notation. WAL rule: log record must be on stable storage before the corresponding data change.
Worked example. Transaction T1 updates account A and B; system crashes after A's change but before B's. Recovery reads the log: T1 not committed → undo A's change (rollback); committed transactions are redone.
Realistic use case. A bank database crashes; on restart it replays the redo log for committed transactions and rolls back uncommitted ones.
Comparison table.
| Technique | Direction | Use |
|---|---|---|
| Undo | reverse uncommitted | rollback |
| Redo | reapply committed | roll forward |
| Checkpoint + log | reduce redo range | faster recovery |
Common mistakes / limitations. Not flushing log before data (violates WAL → lost committed data); keeping very old checkpoints (long redo); assuming recovery is instant (takes time proportional to log).
Exam-ready answer points. Explain recovery (undo/redo, WAL, checkpoints, stable storage); example rollback of uncommitted transaction; contrast backward vs forward recovery.
Self-check questions with answers.
- What is write-ahead logging? Answer: log the change to stable storage before applying it to data.
- Contrast undo and redo recovery. Answer: undo reverses uncommitted changes; redo reapplies committed changes.
Key terms — Unit 8
fault tolerance · crash · omission · timing · response · Byzantine · dependability · availability · reliability · safety · redundancy · SPOF · heartbeat · checkpoint · rollback · message logging · active replication · passive replication · process pair · idempotent · at-least-once · at-most-once · exactly-once · reliable group communication · FIFO · causal · total order · atomic broadcast · state-machine replication · two-phase commit · 2PC · three-phase commit · 3PC · blocking · coordinator · undo · redo · write-ahead logging · stable storage
Unit summary — Unit 8
Fault tolerance handles crash/omission/timing/response/Byzantine failures via detection (heartbeats), masking (redundancy/retry), and recovery. Process resilience uses checkpointing, message logging, rollback-recovery, and active/passive replication. Reliable client-server communication uses timeouts, retransmission, idempotency, and deduplication (at-least/at-most/exactly-once). Reliable group communication provides FIFO/causal/total order via atomic broadcast. Distributed commit (2PC/3PC) makes multi-node transactions atomic but blocks on coordinator failure. Recovery uses undo/redo logging and write-ahead logging to restore consistency.
Unit 9: Security
Teaching hours: 4
Topics in outline order
- 9.1 Introduction to security
- 9.2 Secure channels
- 9.3 Access control
- 9.4 Secure naming
- 9.5 Security Management
9.1 Introduction to security
Plain-language definition and why it matters. Security protects information and services from unauthorized access, disclosure, modification, and denial. It matters because distributed systems span networks and administrative boundaries, expanding the attack surface.
Core theory. Security goals (CIA triad): Confidentiality (only authorized read), Integrity (only authorized change), Availability (accessible when needed). Additional: authenticity (verify identity), non-repudiation (cannot deny actions). Threats: eavesdropping, tampering, impersonation, denial-of-service, unauthorized access. Security mechanisms: encryption, authentication, authorization, access control, firewalls, intrusion detection. Security is a process (defense in depth), not a product.
Syntax / notation. Conceptual; CIA triad diagram.
Worked example. A user logs into a bank app: authenticity (password/MFA), confidentiality (HTTPS encryption), integrity (data not altered in transit), availability (site up), non-repudiation (logs prove who transferred funds).
Realistic use case. An e-commerce site must keep card numbers confidential (encryption), ensure orders aren't altered (integrity), and stay available during sales (availability/DoS protection).
Comparison table.
| Goal | Meaning | Threat it counters |
|---|---|---|
| Confidentiality | authorized read only | eavesdropping |
| Integrity | authorized change only | tampering |
| Availability | usable when needed | DoS |
| Authenticity | verify identity | impersonation |
| Non-repudiation | proof of action | denial |
Common mistakes / limitations. Equating security with encryption alone (ignores availability/auth); assuming internal network is trusted; one-time setup vs ongoing process.
Exam-ready answer points. Define security and CIA triad; add authenticity/non-repudiation; list threats and mechanisms; state defense in depth.
Self-check questions with answers.
- What does the CIA triad stand for? Answer: Confidentiality, Integrity, Availability.
- Name one security threat. Answer: eavesdropping / tampering / impersonation / denial-of-service.
9.2 Secure channels
Plain-language definition and why it matters. A secure channel protects communication between two parties from eavesdropping and tampering. It matters because distributed communication crosses untrusted networks.
Core theory. Secure channel properties: confidentiality (encryption), integrity (MAC/signature), authenticity (endpoint authentication). SSL/TLS: handshake (negotiate cipher, authenticate server via certificate, exchange keys), then encrypted record layer. HTTPS = HTTP over TLS. Public-key cryptography basics: public key encrypts/verifies, private key decrypts/signs; certificates bind identity to public key (issued by CA). Symmetric vs asymmetric: symmetric (AES) fast for bulk data; asymmetric (RSA/ECC) for key exchange and signatures. Diffie-Hellman key exchange establishes a shared secret over an insecure channel.
Syntax / notation. Conceptual: K_AB = session key; C = E(K, M) encryption; S = Sign(sk, M) signature; certificate Cert = CA signs (identity, public key).
Worked example. HTTPS: client connects to https://bank.com; server sends certificate; client verifies CA signature; they negotiate a session key (AES); all HTTP traffic encrypted and MAC-protected.
Realistic use case. A mobile banking app uses TLS to protect credentials and transactions from Wi-Fi eavesdroppers.
Comparison table.
| Symmetric | Asymmetric | |
|---|---|---|
| Key | one shared key | public/private pair |
| Speed | fast | slow |
| Use | bulk data encryption | key exchange, signatures |
| Example | AES | RSA, ECC |
Common mistakes / limitations. Using encryption without authentication (man-in-the-middle); accepting invalid/expired certificates; assuming HTTPS = fully secure (endpoint compromise still possible).
Exam-ready answer points. Explain secure channel properties; describe TLS/HTTPS handshake and certificates; contrast symmetric vs asymmetric; name Diffie-Hellman.
Self-check questions with answers.
- What does TLS provide? Answer: confidentiality, integrity, and authenticity for a channel (encryption + authentication).
- Contrast symmetric vs asymmetric encryption. Answer: symmetric = one shared key, fast (bulk data); asymmetric = public/private pair, slower (key exchange/signatures).
9.3 Access control
Plain-language definition and why it matters. Access control decides who can do what on resources. It matters to enforce confidentiality and integrity by restricting operations to authorized subjects.
Core theory. Subjects (users/processes), objects (files/services), actions (read/write/execute). Models: Discretionary Access Control (DAC — owner decides), Mandatory Access Control (MAC — policy/labels, system decides), Role-Based Access Control (RBAC — permissions assigned to roles, users get roles). Authorization: checking a subject may perform an action on an object. Authentication precedes authorization (who you are vs what you may do). Access control lists (ACLs) and capabilities. Least privilege principle: grant minimum needed.
Syntax / notation. ACL example: file: {alice: rw, bob: r, group dev: rwx}.
Worked example. RBAC: roles student, instructor, admin; instructor can edit grades, student can view own grades; a user assigned instructor role gains edit permission.
Realistic use case. A file server uses ACLs so only the owner and group can edit a document; others read-only.
Comparison table.
| Model | Who decides | Best for |
|---|---|---|
| DAC | owner | flexible, small systems |
| MAC | system policy | high-security (military) |
| RBAC | roles assigned | enterprises, least privilege |
Common mistakes / limitations. Over-privileging (giving admin for convenience); confusing authentication with authorization; stale roles when users change jobs.
Exam-ready answer points. Define access control; subject/object/action; describe DAC/MAC/RBAC; explain authentication vs authorization and least privilege.
Self-check questions with answers.
- What is RBAC? Answer: permissions assigned to roles; users acquire permissions via roles.
- Contrast authentication vs authorization. Answer: authentication = proving identity; authorization = checking permitted actions.
9.4 Secure naming
Plain-language definition and why it matters. Secure naming ensures a name resolves to the correct, authentic entity (not an imposter). It matters because attacks like DNS spoofing redirect users to malicious servers.
Core theory. Threats: DNS spoofing/cache poisoning (false name→IP mappings), man-in-the-middle, hijacking. Defenses: DNSSEC (DNS Security Extensions) signs DNS records so resolvers can verify authenticity; secure key distribution; certificates bind names to public keys (HTTPS validates certificate hostname matches URL); name constraints; trust anchors/root keys. A name is only trustworthy if its binding can be authenticated.
Syntax / notation. DNSSEC: RRSIG record (signature) over a DNS RRset; DNSKEY (public key); DS record (delegation signer) for chain of trust.
Worked example. User visits https://bank.com; the browser checks the server's certificate is signed by a trusted CA and the hostname matches bank.com; DNSSEC (if used) ensures the IP for bank.com wasn't spoofed.
Realistic use case. DNSSEC prevents an attacker on the same Wi-Fi from returning a fake IP for a banking domain.
Comparison table.
| Threat | Defense |
|---|---|
| DNS spoofing/cache poisoning | DNSSEC |
| Name→wrong public key | certificates + CA + hostname check |
| Man-in-the-middle on naming | authenticated key distribution |
Common mistakes / limitations. DNSSEC signs data but does not encrypt it (confidentiality still needs TLS); managing trust anchors is hard; certificate misissuance by a CA breaks trust.
Exam-ready answer points. Define secure naming; name threats (spoofing, poisoning, MITM); describe DNSSEC and certificates; explain chain of trust.
Self-check questions with answers.
- What does DNSSEC do? Answer: digitally signs DNS records so resolvers can verify authenticity (prevents spoofing).
- Why verify a certificate's hostname? Answer: to ensure the public key belongs to the site the user intended (not an imposter).
9.5 Security Management
Plain-language definition and why it matters. Security management is the ongoing administration of security policies, keys, users, and monitoring. It matters because technology (encryption, ACLs) fails without proper administration (key rotation, access reviews, patches).
Core theory. Components: security policy (rules), key management (generation, distribution, storage, rotation, revocation), user/access administration (provisioning/deprovisioning, role assignment), auditing/logging (who did what), intrusion detection, patch management, incident response. Key distribution problem: how to share secret keys securely (solved by asymmetric crypto/key agreement). Certificate lifecycle: issue, renew, revoke (CRL/OCSP), expire. Security administration in distributed systems is harder (multiple domains, no central authority).
Syntax / notation. Conceptual: key lifecycle generate → distribute → store → use → rotate → revoke → destroy.
Worked example. An employee leaves: revoke their certificates/keys, disable accounts (deprovision), rotate any shared secrets they knew, audit their recent actions.
Realistic use case. A cloud provider rotates encryption keys annually and revokes compromised certificates via CRL/OCSP.
Comparison table.
| Task | Example |
|---|---|
| Key management | generate, rotate, revoke keys |
| Access admin | provision/deprovision users, assign roles |
| Auditing | log admin actions, review |
| Patch management | apply security updates |
| Incident response | contain, investigate, recover |
Common mistakes / limitations. Never rotating long-lived keys; not revoking access when users leave; no logs → can't detect/ investigate incidents; treating security as set-and-forget.
Exam-ready answer points. Define security management; list components (policy, key management, access admin, auditing, patching, incident response); explain key lifecycle and certificate revocation (CRL/OCSP).
Self-check questions with answers.
- Name two security management tasks. Answer: key management and access administration (auditing/patching/incident response also valid).
- What are CRL and OCSP used for? Answer: checking certificate revocation status.
Key terms — Unit 9
security · CIA triad · confidentiality · integrity · availability · authenticity · non-repudiation · threat · eavesdropping · tampering · impersonation · denial-of-service · defense in depth · secure channel · TLS · SSL · HTTPS · certificate · CA · symmetric · asymmetric · AES · RSA · Diffie-Hellman · access control · subject · object · DAC · MAC · RBAC · ACL · least privilege · authentication · authorization · secure naming · DNS spoofing · cache poisoning · DNSSEC · chain of trust · security management · key management · CRL · OCSP · incident response
Unit summary — Unit 9
Security goals are CIA (confidentiality, integrity, availability) plus authenticity and non-repudiation, countering threats like eavesdropping, tampering, impersonation, and DoS. Secure channels use TLS/HTTPS with certificates (CA), symmetric (AES) and asymmetric (RSA/ECC) crypto, and Diffie-Hellman. Access control (DAC/MAC/RBAC, ACLs) enforces least privilege; authentication precedes authorization. Secure naming uses DNSSEC and certificates to prevent spoofing/MITM. Security management covers policy, key lifecycle, access administration, auditing, patching, and incident response.
Key terms (full course)
distributed system · transparency · concurrency · scalability · fault tolerance · consistency · QoS · cluster · grid · cloud · peer-to-peer · World Wide Web · DNS · HTTP · CDN · architectural style · middleware · RPC · message-oriented · system architecture · tiers · thread · process · virtualization · hypervisor · VM · container · thin client · thick client · iterative server · concurrent server · thread pool · stateless · stateful · code migration · socket · TCP · UDP · marshalling · RPC · stub · message-oriented · mailbox · multicast · Java RMI · MPI · name · identifier · address · structured naming · attribute-based naming · DNS · resource record · TTL · clock · Lamport · vector clock · mutual exclusion · election · Bully · Ring · location · care-of address · publish/subscribe · gossip · replication · consistency · linearizable · eventual · client-centric · quorum · Nr · Nw · fault tolerance · mutual exclusion · 2PC · 3PC · recovery · security · CIA · TLS · RBAC · DNSSEC · key management
Unit summary (full course)
Unit 1: Introduction — characteristics, design goals, types (cluster/grid/cloud/P2P), Web case study. Unit 2: Architecture — styles, middleware, system architecture, examples. Unit 3: Processes — threads, virtualization, clients, servers, code migration. Unit 4: Communication — foundations, RPC, message-oriented, multicast, Java RMI/MPI. Unit 5: Naming — name/identifier/address, structured naming, attribute-based naming, DNS/GNS. Unit 6: Coordination — clocks, logical clocks, mutual exclusion, election, location, event matching, gossip. Unit 7: Consistency and Replication — consistency models, client-centric, replica management, protocols, Web caching. Unit 8: Fault Tolerance — faults, resilience, reliable communication, group communication, distributed commit, recovery. Unit 9: Security — CIA, secure channels, access control, secure naming, security management.
Detailed practice questions and answer keys
-
Define a distributed system and list five characteristics with one-line meanings. Answer: A distributed system is a collection of independent computers that appears to users as a single coherent system. Characteristics: resource sharing, openness, concurrency, scalability, fault tolerance, transparency (e.g., transparency hides distribution from users; concurrency means many users act at once).
-
Contrast cluster, grid, cloud, and peer-to-peer systems. Answer: Cluster = tightly coupled, single admin. Grid = loosely coupled, geographically distributed, shared owned resources. Cloud = on-demand pooled resources, pay-as-you-go. P2P = decentralized, peers are both clients and servers.
-
Explain the roles of sockets, TCP, and UDP in communication foundations. Answer: A socket is an IP address + port endpoint. TCP is reliable, ordered, connection-oriented (web, email). UDP is unreliable, unordered, connectionless, faster (DNS, streaming).
-
Describe how RPC works, including stubs and failure semantics. Answer: Client calls a local stub; stub marshals parameters and sends to server; server stub unmarshals and invokes the procedure; result returns the reverse. Failure semantics: at-least-once, at-most-once, exactly-once; idempotency makes retries safe.
-
Contrast Lamport and vector clocks; explain happened-before. Answer: Lamport uses one counter per process and gives a partial/causal order but cannot detect concurrency. Vector clocks use a vector (one entry per process) and can detect concurrent events (neither vector ≤ the other). Happened-before (→) = same-process order, send-before-receive, transitivity; unrelated events are concurrent.
-
Explain mutual exclusion requirements and compare centralized, Ricart–Agrawala, and token-ring algorithms. Answer: Requirements: mutual exclusion, freedom from deadlock, freedom from starvation, fairness. Centralized: one coordinator (3 messages, SPOF). Ricart–Agrawala: timestamped multicast (2(N-1) messages). Token ring: circulating token (fair, token-loss risk).
-
State the quorum condition and give a numeric example. Answer: Condition: Nr + Nw > N ensures read and write quorums overlap. Example: N=5, Nw=3, Nr=3 → any read of 3 overlaps any write of 3 (≥1 replica has the latest write).
-
Explain two-phase commit (2PC) and its weakness. Answer: 2PC: voting phase (participants prepare/vote yes/no) and decision phase (coordinator tells commit/abort). Weakness: blocks if the coordinator fails before deciding; coordinator is a single point of failure.
-
Describe TLS/HTTPS and contrast symmetric vs asymmetric encryption. Answer: TLS provides confidentiality, integrity, authenticity via a handshake (certificates from a CA) and encrypted record layer; HTTPS is HTTP over TLS. Symmetric = one shared key, fast (AES, bulk data). Asymmetric = public/private pair, slower (RSA/ECC, key exchange/signatures).
-
List the CIA triad and three access-control models. Answer: CIA = Confidentiality, Integrity, Availability. Access-control models: DAC (owner decides), MAC (system policy), RBAC (roles).
References from the source syllabus
- TU document: https://portal.tu.edu.np/downloads/BCA_Syllabus-compressed_compre_2024_01_30_18_33_22.pdf
- Location: PDF p. 90-93
- Source file: the course outline
- SHA-256: sha256:2755217891f4b4fb1491ca585d027db07131bdfca915c7dcd580466f7f0234e9
- Original course code: CACS352; mapped course code: BCA355; curriculum key: 2018; semester: 6.
- Class load: 4 Hrs./Week (Theory: 3 Hrs, Tutorial: 1 Hr); Credits: 3.
Note: The 2018 curriculum key cites older TU source material; confirm the edition before publication. This guide is a mapped archived outline and is not a new 2025 detailed syllabus.
Content audit (metadata)
- Unit count: 9
- Topic count: 46 (numbered 1.1–9.5 per the mapped archived outline)
- Covered topic count: 46
- Word count: ~16,000
- Status: staged (every TOC topic has substantive content)
- Unresolved items: Verify course code mapping, contact hours, and edition against an official TU source before publication; "(MN)" in topic 4.5 is retained as written in the source (likely MPI).
- Label: mapped archived outline (2018 curriculum); not a new 2025 detailed syllabus.