Part II

System Models

Before you can design or judge a distributed system you need words for it. This Part describes a system at three levels: the hardware it runs on, how its software components are arranged and talk to each other, and the basic assumptions about timing, failures and attackers that hold whatever the arrangement. Every later Part, and a good share of the exam, uses this vocabulary.

  • You willname the three kinds of model and describe the three generations of distributed systems.
  • You willcompare client-server, peer-to-peer and every placement strategy and variant, with a benefit and a cost for each.
  • You willtell layering from tiering, and explain middleware and the end-to-end argument.
  • You willdefine synchronous and asynchronous systems, classify failures, and describe the enemy of the security model.
2.1

Why Model a Distributed System?

A distributed system is a collection of computers that cooperate by sending each other messages over a network. Real ones are enormously complicated: thousands of machines, many programs, networks that slow down and machines that fail. To reason about such a thing at all, you have to leave most of the detail out and keep only what matters for the question you are asking. That is what a model does.

Definition · model

A model is an abstract, simplified but consistent description of one aspect of a system's design. "Abstract" means it ignores detail that does not matter for that aspect; "consistent" means it never contradicts itself.

Models earn their keep in three ways. They help us classify and understand existing implementations and see their strengths and weaknesses. They let us build new systems from pre-validated building blocks, because a design pattern that is known to work can be reused. And they make our design assumptions explicit, so that we can check whether those assumptions really hold. For example, an algorithm that assumes "every message arrives within one second" is only safe on a network where that is true, and a model forces you to write that assumption down.

Three kinds of model exam

The textbook (CDK §2.1) looks at a distributed system from three levels, from the concrete to the abstract. Each answers a different question about the same system.

PHYSICAL MODEL the hardware: nodes and links NETWORK What computers and devices, and what network joins them? ARCHITECTURAL MODEL components, placement, relationships client client server Which roles, placed where, talking how? (client-server, P2P…) FUNDAMENTAL MODELS properties shared by every architecture Interaction timing, delays Failure what can break Security the enemy What can we assume, whatever the design?
One system, three levels of description. Read left to right from concrete to abstract. The physical model is about boxes and wires; the architectural model is about which program does what, and where; the fundamental models state assumptions about time, failure and attack that hold for any architecture. Colours used throughout this Part: blue = client, red = server, green = peer, violet = middleware, amber = a third party such as a proxy or database.
Physical model

Describes the hardware: the computers and devices (the nodes) and the networks that join them (the links), abstracted from specific technologies.

Architectural model

Describes the computational and communication tasks of the system's elements, where they are placed, and how they relate. Client-server and peer-to-peer are examples.

Fundamental models

An abstract, formal description of properties common to all architectures. There are three: interaction, failure and security.

The difficulties every design must face

Whatever architecture you pick, the same four kinds of trouble will come for it. CDK §2.1 groups them like this, and each has a typical answer. Notice how the answers foreshadow the rest of the Part: redundancy, modular structure, failover and built-in security.

Widely varying modes of use

Spiky, patchy, demanding

Workloads can spike; parts of the system may be disconnected or poorly connected (mobile devices); multimedia needs special bandwidth or latency. Answer: distribute the workload, provide redundant services, aim for high availability.
Wide range of environments

Heterogeneous and huge

Different hardware, operating systems and networks, at scales from tens to millions of computers. Answer: a flexible, modular structure.
Internal problems

Clocks, conflicts, faults

Clocks are not synchronised, updates can conflict, and hardware and software fail. Answer: interaction patterns that resolve concurrency, and an organisation that supports failover (switching to a backup).
External threats

Attackers

Attacks on integrity and secrecy, and denial-of-service attacks that swamp a service. Answer: security built into the infrastructure, not bolted on.

Design must look forward

The lecturer's warning is that a design which suits 10 users can be terrible for 10,000, so you must think about where the system is heading. His example is a dictionary server (a service that looks up word meanings), which could be built in three quite different ways.

1 · MONOLITHIC ONE COMPUTER dictionary program Simple, but only local users, and it cannot grow. 2 · CLIENT-SERVER server full dictionary client + cache client + cache client + cache Updates made centrally; clients cache their earlier lookups. 3 · PEER-TO-PEER peer A–F peer G–L peer M–R peer S–Z Each peer holds one segment; capacity grows with the peers.
Same service, three architectures. The monolithic program is fine for one user and useless for a city. The client-server version centralises updates and lets clients cache answers, but the one server can become a bottleneck. The peer-to-peer version spreads the dictionary over the users' own machines. Sections 2.4 and 2.5 explain these trade-offs.
Check yourselfA design document says: "messages may take arbitrarily long to arrive, and any process may crash at any time." Which kind of model is this statement part of?
  1. A physical model
  2. An architectural model
  3. A fundamental model
  4. None: it is an implementation detail

C, a fundamental model (specifically the interaction and failure models). It says nothing about which hardware is used (physical) or how components are arranged (architectural); it states assumptions that would hold whatever the architecture. A is wrong because no nodes or links are described; B is wrong because no roles or placement are described.

Check yourselfGive the three reasons for building models of distributed systems.

(1) To classify and understand implementations and identify their strengths and weaknesses; (2) to build new systems from pre-validated building blocks; (3) to make design assumptions explicit, so they can be checked against the real system.

In short
  • A model is an abstract, simplified, consistent description of one aspect of a design.
  • There are three kinds: physical (hardware), architectural (components, placement, relationships) and fundamental (interaction, failure, security).
  • Every design faces varying use, varied environments, internal problems and external threats, and must look forward to growth.
2.2

Physical Models

The most concrete question you can ask about a distributed system is: what is it physically made of? The answer has changed enormously over forty years, from a few dozen office PCs to billions of phones, sensors and data-centre servers, and each change brought new problems. A physical model describes the hardware without getting lost in brand names or cable types.

Definition · physical model exam

A physical model is a representation of the underlying hardware elements of a distributed system that abstracts away from specific details of the computer and networking technologies.

The simplest one is the baseline physical model: an extensible set of computer nodes interconnected by a computer network for the required passing of messages.

COMPUTER NETWORK + new node nodes: computers, devices links
Nodes plus a network, nothing more. The baseline model says only that there is an extensible set of nodes and that messages pass between them over a network. The dashed node is the point: the set can grow.

Three generations of distributed systems exam

CDK Fig. 2.1 traces how the physical basis has grown. Read the picture and the table along the rows: the systems grow in scale and heterogeneity (variety of hardware and software), while openness (being built on published, standard interfaces so anyone can extend them) and quality of service (guarantees about performance and reliability) rise from low priorities to major research challenges.

EARLY · LATE 1970s–EARLY 80s printer file server LAN 10–100 nodes on one LAN scale: small INTERNET-SCALE · 1990s ON network of networks, global, across organisations scale: large CONTEMPORARY cloud: a pool of nodes embedded sensors (IoT) mobile mobile, embedded and cloud nodes scale: ultra-large
Each generation keeps the last one and adds to it. Early systems were one office LAN; Internet-scale systems join many networks owned by different organisations; contemporary systems add nodes that move (phones), nodes hidden inside everyday objects (sensors) and pools of nodes that act as one (cloud).
Early (late 1970s–early 80s)Internet-scale (1990s on)Contemporary
Physical basis10–100 nodes on a LAN (Ethernet); limited Internet connectivity; printers, file servers, emailNodes on a network of networks; global services across organisations; clusters, grids, P2PMobile, embedded and cloud nodes; up to hundreds of thousands of nodes; IoT
ScaleSmallLargeUltra-large
HeterogeneityLimitedSignificant: platforms, languages, middlewareAdded dimensions, incl. radically different architectural styles
OpennessNot a prioritySignificant priority: open standards, middleware (CORBA, web services)Major research challenge
Quality of serviceIn its infancySignificant priorityMajor research challenge

Three assumptions that broke

In the earlier generations a node could be assumed to be static (it stays put), discrete (it is a separate, recognisable computer) and autonomous (it works on its own). Three trends have broken each of these assumptions in turn.

TrendOld assumption it breaksWhat changes
Mobile computingNodes are staticNodes move between networks, so the system needs service discovery (finding services nearby) and spontaneous interoperation (working with them without prior set-up).
Ubiquitous computingNodes are discreteComputers are embedded in everyday objects (a thermostat, a car), so a node is no longer a separate box you can point at.
Cloud computing and clustersNodes are autonomousPools of nodes jointly provide one service, so no single node stands alone.

Systems of systems

At the ultra-large scale we meet systems of systems: complex systems whose subsystems are systems in their own right, which come together to perform a task. Flood prediction is the textbook example.

SYSTEM OF SYSTEMS · FLOOD PREDICTION Sensor network river and rain sensors Cluster simulation runs flood models Historical analysis compares with past floods Early warnings alerts to mobile phones
Each box is a complete system that could run on its own. A sensor network, a compute cluster, a data-analysis system and a phone-alert service are owned and built separately; together they perform a task none could do alone.
Check yourselfIn which generation did openness first become a significant priority, and what made it necessary?

The Internet-scale generation (1990s on). Systems now spanned many organisations with significant heterogeneity of platforms, languages and middleware, so they could only work together through open standards and middleware such as CORBA and web services. In the early generation openness was not a priority; in the contemporary one it has become a major research challenge.

Check yourselfWhich trend breaks the assumption that nodes are autonomous?
  1. Mobile computing
  2. Ubiquitous computing
  3. Cloud computing and clusters
  4. Open standards

C. In cloud computing and clusters, pools of nodes jointly provide one service, so a node no longer works on its own. Mobile computing (A) breaks static; ubiquitous computing (B) breaks discrete; D is not one of the three trends.

In short
  • A physical model represents the hardware while abstracting from specific technologies; the baseline is an extensible set of nodes joined by a network.
  • Three generations: early (small LAN), Internet-scale (network of networks, open standards), contemporary (mobile, embedded, cloud; ultra-large; systems of systems).
  • Mobile, ubiquitous and cloud computing broke the assumptions that nodes are static, discrete and autonomous.
2.3

Architectural Models: the Elements

Knowing the hardware tells you nothing about how the software is organised. Two systems on identical machines can behave completely differently depending on which program does what, and where. An architectural model captures exactly that organisation, so you can compare designs and predict how they will cope with growth and failure.

Definition · architecture exam

An architecture is the structure of a system in terms of separately specified components and their interrelationships, designed to meet present and likely future demands. The overall goal is a system that is reliable, manageable, adaptable and cost-effective.

An architectural model does three things. It (i) simplifies and abstracts the functions of the individual components; it considers their (ii) placement, meaning how data and workload are distributed across machines; and it considers their (iii) interrelationships, meaning their roles and the patterns in which they communicate. The very first simplification is to classify every process as a server, a client or a peer.

Four key questions exam

Designing an architecture comes down to answering four questions. Understanding the trade-offs between the possible answers is the key design skill, and the rest of this Part takes the questions one at a time.

1 What communicates? processes (system view) objects components web services entities · 2.3 2 How do they talk? interprocess communication remote invocation indirect communication paradigms · 2.3 3 Which roles? client and server peers roles · 2.4 4 Placed where? multiple servers caching, proxies mobile code mobile agents placement · 2.5
The four questions behind every architecture. Any design can be described by its answers: what communicates, how, in which roles, and where it is placed on the physical machines.

Question 1: what communicates?

There are two ways to answer. From a system-oriented view, the communicating entities are processes (running programs), so a distributed system is simply a set of processes plus interprocess communication (IPC), the mechanisms processes use to send each other data. Two caveats apply. In some sensor networks the tiny devices have no operating-system support for processes, so the entities are the nodes themselves. And, strictly speaking, the real endpoints of communication are threads, the separate sequences of execution inside a process (Part IV).

From a problem-oriented view, which is closer to how programmers think, there are three kinds of entity.

OBJECT Account IDL interface unit of decomposition COMPONENT Billing provides requires dependencies made explicit WEB SERVICE Quote service https://…/quote caller XML organisation boundary combined across organisations
Three ways to package functionality. A lollipop (circle on a stick) is an interface the entity offers; the socket (half circle) on the component is an interface it needs from someone else. Only the web service crosses an organisation boundary.
  • Objects are the natural units of decomposition in object-oriented programs. They are accessed through interfaces written in an IDL (interface definition language), a notation that describes the methods an object offers independently of any programming language (Part VI).
  • Components specify both the interfaces they provide and the interfaces they require. Because the dependencies are explicit, a component comes with a complete contract, which lets third parties build components and compose them.
  • Web services are identified by a URI (Uniform Resource Identifier, a web-style name such as a URL). Their interfaces are described and discovered as XML (a text format for structured data), and they communicate by XML messages over Internet protocols such as HTTP.

The difference in use matters: objects and components typically build tightly coupled applications inside one organisation, whereas web services are complete services in their own right that can be combined across organisational boundaries.

Question 2: how do they communicate? exam

Once you know what communicates, you need to choose how. There are three paradigms, running from raw message exchange up to communication through a third party.

1 · INTERPROCESS COMM. p q bytes low-level send / receive sockets, multicast 2 · REMOTE INVOCATION client server op(args) result two-way: call a remote operation request-reply, RPC, RMI 3 · INDIRECT sender receiver receiver via a third entity (violet) queues, groups, pub-sub, DSM
From raw bytes to a go-between. IPC moves bytes; remote invocation wraps them into "call this operation, give me the result"; indirect communication puts an intermediary (violet) between sender and receivers so that neither needs to know about the other.
ParadigmMeaningExamples
Interprocess communicationLow-level communication between processesMessage passing, sockets, multicast (Part III)
Remote invocationTwo-way exchange that calls a remote operationRequest-reply, RPC, RMI (Part VI)
Indirect communicationVia a third entity; decouples sender and receiverGroup communication, publish-subscribe, message queues, tuple spaces, DSM (Part VII)

Remote invocation comes in three forms, each built on the one before.

  • Request-reply is the primitive form: a pairwise exchange of a request message and a reply message. The messages carry the operation, its arguments and its results in encoded form; turning program data into a sequence of bytes for transmission is called marshalling. HTTP works this way, and request-reply underlies RPC and RMI.
  • RPC (Remote Procedure Call) lets a program call a procedure in another process as if it were local, hiding the marshalling and messaging. It gives at least access transparency (local and remote calls look the same) and location transparency (the caller need not know where the procedure runs).
  • RMI (Remote Method Invocation) is RPC for distributed objects: it adds object identity and the ability to pass references to remote objects as arguments and results.

Direct coupling versus space and time uncoupling

The paradigms also differ in how tightly they tie sender and receiver together. Remote invocation is directly coupled: the sender must name the receiver, and both must be running at the same moment. Indirect communication removes both requirements. It gives space uncoupling, because the sender need not know who the receivers are, and time uncoupling, because sender and receiver need not exist at the same time.

DIRECT COUPLING · REMOTE INVOCATION sender receiver q to q: op() the sender names the receiver, and both run at the same time INDIRECT · SPACE AND TIME UNCOUPLING sender sender exits intermediary: queue, group, tuple space… (holds m) put m the sender need not know who will receive (space) receiver not running yet take m nor exist at the same time (time)
The intermediary breaks both links. In the top picture the sender must know q's name and q must be running. In the bottom picture the sender has already exited before the receiver even starts, and it never learned who the receiver was.

There are five indirect techniques; Part VII covers each in depth.

  • Group communication delivers a message one-to-many, to a group identifier. Recipients join the group, and the system manages membership and member failures.
  • Publish-subscribe uses an intermediary that routes events from many publishers to the subscribers that registered interest in them.
  • Message queues are point-to-point: producers send messages to a queue, and consumers receive them from it or are notified when they arrive.
  • Tuple spaces let processes put structured records (tuples) into a persistent space, where other processes can read or remove them by pattern.
  • Distributed shared memory (DSM) lets processes read and write shared data as if it were in their own address space, even though there is no shared physical memory.
Check yourselfA stock-trading app posts "price changed" events; any number of dashboards that have registered interest receive them, and the app never knows which ones. Which paradigm, and which kind of uncoupling does it show most clearly?

It is indirect communication, specifically publish-subscribe. The app does not know who the receivers are, which is space uncoupling. (If the events were also stored for dashboards that start later, it would show time uncoupling too.) Remote invocation would not fit, because it requires the caller to name each receiver.

Check yourselfHow does a component differ from an object, and what does the difference buy you?

An object declares only the interface it offers. A component declares both the interfaces it provides and those it requires, so its dependencies are explicit. That gives a complete contract, which lets independent (third-party) developers build components and compose them without hidden dependencies.

In short
  • An architecture is components plus their interrelationships, aiming to be reliable, manageable, adaptable and cost-effective.
  • Four questions: what communicates (processes; objects, components, web services), how (IPC, remote invocation, indirect), which roles, and where placed.
  • Remote invocation is directly coupled; indirect communication gives space and time uncoupling.
2.4

Roles: Client-Server and Peer-to-Peer

The third key question is about roles and responsibilities: does one machine do the work for everyone, or does everyone share it? The two main answers, client-server and peer-to-peer, are the most important architectural styles in the subject.

Client-server exam

In a client-server architecture, client processes interact with individual server processes, possibly on separate hosts, to access the shared resources that the servers manage. A resource here means anything that can usefully be shared: a file, a database, a printer, a web page. This is the most important and most widely used architecture.

Client and server are roles

"Client" and "server" describe what a process is doing in one interaction, not what it is forever. So a server may be a client of other servers. A web server is a client of a file or database server, and of DNS (the Internet's name service, Part IX) when it looks up a host name.

A server acting as a client, one message at a time
client server database server 1 · request blocked, waiting 2 · query here the server is a client 3 · data 4 · reply continues execution
  1. Three processes: a client (blue), a server (red) and a database server (amber). Time runs down the page.
  2. The client sends a request and then blocks: it waits, doing nothing else, until the reply arrives (gold bar).
  3. To answer, the server needs data it does not hold, so it sends a query to the database server. In this exchange the server is playing the client role.
  4. The database server replies with the data. The server's role as a client is over.
  5. The server finishes the work and sends the reply. The client unblocks and continues execution.

A search engine shows roles changing even more clearly. It is a server to millions of browsers, but its web crawlers (programs that fetch pages to index) act as clients of other web servers. The crawler threads and the query-answering threads run concurrently, synchronising only on the shared index they both use.

Weakness of client-server

A service offered at a single address does not scale beyond the processing capacity and network bandwidth of the one host it runs on, and that host is a single point of failure: if it crashes, the service is gone.

Peer-to-peer exam

In a peer-to-peer (P2P) architecture, all processes play similar roles and cooperate as peers, with no distinction between client and server. They run the same program and offer the same interfaces to each other.

The key insight is that the users' own computers and network links can support the service, so resources grow with the number of users: every new user brings storage, processing and bandwidth as well as demand. Each peer holds only part of the shared data, and the load is spread across many machines. Objects are replicated (copies are kept on several peers), both to spread the load and to make the system resilient when peers disconnect, which they do all the time. All of this makes P2P substantially more complex than client-server: something must decide where data goes, how to find it, and how to keep copies.

client client client client server bottleneck and single point of failure
Client-server: asymmetric. Every request lands on the one server, so its capacity caps the whole system.
peerobjects a, x peerobjects b, c peerobjects d, x peerobjects e, f peerobjects g, h x is replicated: it survives one peer leaving
Peer-to-peer: symmetric. Every peer is both client and server; the data is spread out and replicated, so there is no central point to overload or attack.

Examples include Napster (not pure P2P, because it had a central index), Gnutella, BitTorrent, a distributed whiteboard and blockchain. The slides also show P2P with a centralised index server, as used by WhatsApp, Skype and WeChat: a server helps peers find each other, and then the peers interact directly. The lecturer adds that P2P has no central point of failure or control, which makes it hard for an adversary to deny service, and that some peers contribute more than others (seeds in BitTorrent, super-peers elsewhere).

index server records who is where peer A peer B 1 register 2 where is B? 3 B's address 4 talk directly
The server only introduces; the peers do the talking. (1) B registers where it can be reached; (2) A asks the index where B is; (3) the index answers; (4) the conversation itself flows peer to peer (teal), never through the server.

Static versus dynamic responsibility

The two styles also allocate responsibility differently. Client-server allocates it statically: a file server serves files, not web pages, and that never changes at run time. P2P allocates it dynamically: a search, for instance, may be delegated to different peers depending on who is online at that moment.

Client-serverPeer-to-peer
RolesAsymmetric, fixedSymmetric
ResponsibilityStaticDynamic
ScalabilityLimited by the server and its bandwidthGrows with the number of peers
FailureServer is a single point of failure unless replicatedNo single point of failure
Management, securityCentral, simplerHard; peers are users' machines that come and go
ComplexityLowHigh (placement, lookup, replicas)
Check yourselfTrue or false: "A web server is a server, so it can never be a client."

False. Client and server are roles in an interaction. A web server is a client of DNS when it resolves a name, and of a file or database server when it fetches content. A search engine's crawlers are clients of other web servers.

Check yourselfWhy does a P2P file-sharing system's capacity grow as more users join, while a client-server system's capacity does not?
  1. P2P uses faster networks
  2. Each new peer contributes its own storage, processing and bandwidth
  3. P2P compresses data better
  4. Clients in client-server refuse to share

B. In P2P the users' own machines and links support the service, so each newcomer adds resources as well as demand. In client-server every newcomer only adds demand on the fixed server.

Check yourselfWhy is Napster described as "not pure P2P"?

Because it relied on a central index server to find which peer held which file. The file transfers themselves were peer to peer, but the lookup was client-server, the same hybrid as WhatsApp or Skype's directory.

In short
  • Client-server: clients access resources managed by servers; roles, not identities, so a server can be a client. Weakness: limited scale and a single point of failure.
  • Peer-to-peer: symmetric peers whose resources grow with the number of users, with replicated objects; the price is complexity and harder management and security.
  • Client-server allocates responsibility statically, P2P dynamically.
2.5

Placement Strategies exam

The fourth key question is placement: deciding which machine and which process each service or data object lives on. It sounds like a deployment detail, but placement largely determines a system's performance, reliability and security. The right choice depends on the patterns of communication between components, on how reliable and loaded each machine is, and on the quality of the links between them. There are four strategies.

Strategy 1

Multiple servers

Several servers together provide one service, by partitioning or replicating its objects.
Strategy 2

Caching

Keep copies of recently used objects close to the clients that use them.
Strategy 3

Mobile code

Download code from a server and run it at the client.
Strategy 4

Mobile agents

Send a running program, with its data, to visit the machines that hold the resources.

1 · Mapping services to multiple servers

A single server caps the whole system (2.4). The first fix is to let several servers on separate hosts provide one service together. They can split the work in two ways. In partitioning, each server manages its own share of the objects, as the Web does: each web server holds only its own pages. In replication, each server holds a copy of the same objects, as Sun NIS (Network Information Service) does: every NIS server holds a copy of the password file, so any of them can check a login.

ONE SERVICE client server 1 objects A–H server 2 objects I–P server 3 objects Q–Z get K each server: its own share
Partitioning. The objects are divided, so each request goes to the one server that holds that object. Load is shared, and the service as a whole can grow.
ONE SERVICE (NIS) client server 1 passwd (copy) server 2 passwd (copy) server 3 passwd (copy) login? any copy can answer
Replication. Every server holds a full copy, so any one can answer (faint arrow: an alternative), and the service survives a server crash (red cross). The price is keeping the copies consistent.

A cluster is a closely coupled version of the same idea: up to thousands of cheap commodity computer boards in one place, working as one service. The lecture's examples are Google's clusters, to which clients are redirected via DNS; replicated Oracle databases; Kubernetes (a system that runs and replicates services across a cluster); and microservices, where an application is split into small independent services, each on its own servers, behind a load balancer that spreads incoming requests across them. The gains are load sharing, availability (the service is up when needed) and fault tolerance (it keeps working when parts fail).

CLUSTER OF COMMODITY MACHINES client sent here by DNS load balancer spreads requests orders service accounts service payments service replicated database
Partitioning by function plus replication. Microservices split one application into independent services (a form of partitioning); the load balancer shares requests among servers; the database is replicated for availability. DNS picks which cluster a client reaches in the first place.

2 · Caching exam

Definition · cache

A cache is a store of recently used data objects that is closer to one client or a set of clients than the objects themselves. When an object is requested, the cache supplies it if it holds an up-to-date copy; otherwise it fetches a copy, stores it, and evicts (throws out) other objects if it needs the room.

Browsers keep a cache of pages on the user's own machine, and before reusing a cached page they can validate it with a special HTTP request that asks the server whether it has changed. A web proxy server goes one step further and provides a shared cache for many clients, typically everyone in one organisation. A proxy in general is an intermediary that acts on behalf of someone else; here the proxy fetches pages on behalf of its clients.

A web proxy cache: a miss, then a hit
client A client B proxy server SHARED CACHE Y Z X miss: no copy of X X stored hit: X is up to date evicts old objects when full firewall INTERNET web server 1 web server 2 1 · GET X 2 · GET X 3 · X 4 · X 5 · GET X 6 · X (from cache)
  1. Clients A and B (blue) sit inside an organisation and reach the Web through a proxy server (amber) whose shared cache already holds pages Y and Z. A firewall separates the organisation from the Internet.
  2. Client A asks the proxy for page X (message 1). The cache has no copy: a miss.
  3. The proxy fetches X from web server 1 on A's behalf (message 2), crossing the firewall and the wide-area Internet.
  4. The server returns X (message 3), and the proxy stores a copy in its cache, evicting an old object if it were full.
  5. The proxy passes X to client A (message 4).
  6. Later, client B asks for the same page X (message 5). This time the cache holds an up-to-date copy: a hit.
  7. The proxy answers B straight from its cache (message 6). Nothing crossed the Internet and web server 1 did no work, so B got a faster answer and the network and server carried less load.

The benefits: a proxy cache increases availability and performance by reducing the load on the wide-area network and on web servers. Proxies can also give machines inside an organisation controlled access to the outside through a firewall (a barrier that filters traffic between an internal network and the Internet). The slides add that proxies give replication transparency: the client cannot tell whether it is talking to the original or a copy. The cost is stale data: a cached copy can be out of date, which is why caches check whether a copy is up to date.

3 · Mobile code

Sometimes the slow part is the network itself: every click the user makes would need a round trip to the server. Mobile code solves this by moving the code instead: code downloaded from a server runs at the client. Java applets were the classic example. The user's request downloads the applet's code, and the user then interacts with it locally.

Mobile code: a stock-price applet
CLIENT HOST SERVER HOST browser web server StockApplet.class SANDBOX stock applet server's code, running at the client local files user 1 · get page 2 · applet code interacts locally:no network delay 3 · push: new price no file access
  1. A client host runs a browser; a server host runs a web server that stores the applet's code. The gold dashed box is the sandbox, a restricted environment in which downloaded code will run.
  2. The browser requests a page that contains the applet (message 1).
  3. The applet's code is downloaded (message 2) and starts running inside the sandbox. Note the colour: it is the server's code, now executing on the client's machine.
  4. The user interacts with the applet locally: scrolling a chart or changing a view needs no round trip, so the response is immediate and the server does no work.
  5. The push model: the server itself initiates an update, sending a new stock price to the running applet (message 3) without the user asking.
  6. The risk to the client: if the applet tries to read the user's local files, the sandbox blocks it. Browsers give applets no local file access, because downloaded code cannot be trusted.
Advantages
  • Good interactive response: no network delay per action.
  • Less load on the server.
  • Supports a push model, where the server initiates updates (the stockbroker applet).
Disadvantages: trust, both ways
  • Mobile code threatens the client's local resources, so browsers sandbox applets.
  • The server cannot trust code running on the client, so mobile code is unsuitable for, say, banking logic: the client could tamper with it.

4 · Mobile agents exam

Definition · mobile agent

A mobile agent is a running program, both its code and its data, that travels from computer to computer carrying out a task on someone's behalf, and eventually returns with the results.

The idea is to "bring the small program to the big data". Instead of making many remote invocations across the network to a server that holds a large amount of data, the agent goes there and makes local invocations, which lowers the communication cost. Uses include software installation and maintenance, comparing prices across vendors, and mining distributed data; JADE is a toolkit for building agents.

A mobile agent comparing prices
migrate: code + state ALICE'S HOST VENDOR A $30 VENDOR B $25 VENDOR C $28 agentbest: none agentbest: A $30 agentbest: B $25 agentbest: B $25 C checks: acts for whom?grants only some resources agentbest: B $25
  1. Alice wants the cheapest price for an item sold by three vendors. Each vendor's host holds a large price database.
  2. An agent (gold) is created on Alice's host: a running program with its code and its data, here "best price so far: none".
  3. The agent migrates to vendor A, taking its code and its state with it. It reads A's prices with local calls and records "best: A $30".
  4. It moves on to vendor B and finds a better price: "best: B $25".
  5. At vendor C the host must protect itself: it checks the securely attached identity of the user the agent acts for (Alice) and decides which resources to allow. C's price ($28) is not better, so the agent keeps "B $25".
  6. The agent returns home with the result. Only the agent crossed the network, rather than many request-reply messages. (Had any vendor refused it access, the task would have failed.)

The disadvantages are again about security, in both directions. The agent is a threat to every host it visits, so a host must decide which of its resources to allow, based on the securely attached identity of the user the agent acts for. The agent is itself vulnerable: if a host refuses it access, its task fails, and a hostile host could tamper with it. And because most of these tasks can be done in other ways (web crawlers, for instance, simply use remote invocation), mobile agents have limited applicability.

Mobile code and mobile agents are easy to confuse, so here is the difference side by side.

Mobile codeMobile agent
What movesCode, once, from server to clientA running program plus its state, from host to host
Main gainInteractive responseLess remote communication
Security riskTo the clientTo the hosts visited, and to the agent itself
Check yourselfA university wants students' web browsing to be faster and to reduce its Internet bill, because many students load the same pages. Which placement strategy fits, and what is its main risk?

Caching with a shared web proxy server. Pages fetched by one student are kept in the proxy's cache, so later requests are answered locally, lowering latency and wide-area traffic (and the proxy can sit at the firewall). The main risk is stale data: a cached copy may be out of date, so the cache must check that its copy is up to date before using it.

Check yourselfWhich statement about mobile agents is correct?
  1. They are downloaded once and run only at the client, like an applet.
  2. They carry code and data between hosts, replacing remote invocations with local ones.
  3. They are widely used because they pose no security risk.
  4. They reduce the work each host does by running everything at home.

B. A describes mobile code. C is wrong: agents threaten the hosts they visit and are vulnerable themselves, which is one reason their use is limited. D is backwards: the agent goes to where the data is.

In short
  • Placement decides performance, reliability and security.
  • Multiple servers partition (Web) or replicate (NIS) objects; caches and proxies keep up-to-date copies near clients.
  • Mobile code runs server code at the client for responsiveness and push, at a risk to the client; mobile agents carry code and state to the data, at a risk to hosts and agent.
2.6

Other Client-Server Variants

Beyond the four placement strategies, the slides describe several more ways of dividing work between a user's device and the servers. They differ in one question above all: where does the application actually run?

Network computers and thin clients

Network computers download their operating system and applications from a remote file server and run them locally. Because nothing important is stored on the machine, users can move between machines freely, and upgrades are made once, centrally. The approach has since been superseded by virtual network computing (below).

Definition · thin client exam

A thin client is a software layer that supports a window-based user interface local to the user while the applications execute on a remote compute server. Examples are X-11, Windows Remote Desktop, VNC and Citrix.

file server stores OS and applications code and files NETWORK COMPUTER OS + apps run here after download
Network computer: download, then run locally. The network carries code and files; the processing happens on the user's machine.
COMPUTE SERVER applications run here all the processing keystrokes, clicks screen updates thin client shows the UI only
Thin client: run remotely, show locally. Only UI events go up and screen images come down, so a weak device can use powerful applications.
Network computerThin client
Application runsLocally, after downloadOn the remote server
Network carriesCode and filesUI events and screen updates

Thin clients have clear advantages: weak, cheap devices gain access to powerful services; maintenance, upgrades and security are handled centrally; and users have access from anywhere. The drawback is that highly interactive graphics, such as CAD (computer-aided design) or image processing, suffer unacceptable delay, because every mouse movement must go to the server and every new frame must come back, adding network and operating-system latency to each action.

VNC (Virtual Network Computing) shows how simple the protocol can be. A viewer talks to a VNC server using a framebuffer protocol (the framebuffer is the block of memory holding the screen's pixels), whose single operation places a rectangle of pixels at a given position on the screen. Because that is so low-level, it works with any operating system or application.

viewer (user's device) VNC server changed area rect(x, y, w, h, pixels) key, click(x, y) one operation: "put this rectangle of pixels here" so any OS and any application can be shown
The whole protocol is "update a rectangle". When part of the server's screen changes (gold), only that rectangle's pixels are sent. Input travels the other way as key and click events.

Today's cloud applications used through a browser, such as an online spreadsheet, follow the same thin-client, client-server idea. The trend is to move complexity out of end devices and into Internet services.

Mobile devices and spontaneous networking

The last variant deals with devices that move. A laptop or phone joins and leaves networks (a hotel's wireless LAN, say) and wants to use whatever local services are there, such as a printer or music. It needs two things: an easy way to connect, such as DHCP (a protocol that automatically hands a newly arrived device a network address), and a discovery service. A discovery service has two parts: a registration service, where servers publish the services they offer, and a lookup service, where clients find services that meet their requirements. Apple's Bonjour and UPnP work like this; naming in general is covered in Part IX.

HOTEL WIRELESS LAN guest laptop just arrived DHCP server hands out an address discovery service registration + lookup printer service music service 1 2 2 3 lookup "printer" 4 print
Arrive, connect, discover, use. (1) DHCP gives the newcomer an address; (2) services have registered with the discovery service; (3) the laptop looks up a service that meets its needs; (4) it then uses the service directly.

Summary of the variants exam

Every variant buys a benefit at a cost. This table is worth learning as a whole, because a 5-mark question often asks for a variant, a reason for using it, and its downside.

VariantBenefitCost or risk
Clients and a single serverSimple, central controlBottleneck, single point of failure
Multiple serversScale, availabilityReplica consistency
Proxy servers with cachesLower latency and loadStale data
Peer processesCapacity grows with usersComplexity, security
Mobile codeResponsiveness, pushClient security
Mobile agentsLess communicationHost and agent security
Network computersCentral managementNetwork dependence
Thin clientsWeak devices, central adminLatency for graphics
Spontaneous networkingUbiquitous accessDiscovery, connectivity, security
The lecturer's theme: trade-offs

Moving load to the client (mobile code) improves responsiveness but risks security. Moving complexity to the server (thin clients, cloud apps) lowers what the client needs, but every action now depends on the network.

Check yourselfA design firm considers giving its engineers thin clients connected to a central compute server for their 3D CAD work. What is the main objection?

Thin clients are usually not suitable for highly interactive graphical work. Every rotation of a 3D model would need input sent to the server and new screen images sent back, so network and OS latency would make the response unacceptably slow.

Check yourselfIn one sentence each, how do a network computer and a thin client differ in where the application runs and what the network carries?

A network computer downloads the OS and applications and runs them locally, so the network carries code and files. A thin client runs nothing but the UI; the application runs on the remote server, so the network carries UI events up and screen updates down.

In short
  • Network computers download and run locally; thin clients run everything remotely and only display (bad for interactive graphics). VNC's protocol just places rectangles of pixels.
  • Mobile devices need easy connection (DHCP) and discovery (registration plus lookup).
  • Every variant is a trade-off between where the work runs, responsiveness, management and security.
2.7

Architectural Patterns

Designers keep meeting the same problems, and the same arrangements of elements keep solving them. An architectural pattern is such a recurring composite structure, built from the elements of the previous sections, that is known to work well in given circumstances. Learning the patterns means you can recognise a design quickly and reuse one that works. This section covers layering, tiering and AJAX, and then three more patterns: proxy, brokerage and reflection.

Layering exam

In layering, a system is split into a stack of layers. Each layer uses the services of the layer below and offers a service (an abstraction) to the layer above, hiding how it is implemented. A programmer working at one layer only needs to understand the interface of the layer directly beneath.

each layer uses the one below Applications, services Middleware Operating system Computer and network hardware masks heterogeneity; gives a convenient programming model PLATFORM lowest layers, implemented independently in each computer x86/Windows · x86/Linux · ARM/Android · iPhone/iOS examples of platforms
Two layers matter most here. The platform (OS plus hardware) differs from machine to machine; middleware (violet) sits on top of it and hides those differences, so applications see the same abstractions everywhere.
Platform

The lowest hardware and software layers. They are implemented independently in each computer and provide an interface that supports communication and coordination between processes. Examples: x86/Windows, x86/Linux, ARM/Android, iPhone/iOS.

Middleware exam

A layer of software whose purpose is to mask heterogeneity and provide a convenient programming model to application programmers. It offers abstractions such as RMI, group communication, event notification, placement and replication of shared data, and multimedia streaming. Examples: Sun RPC, CORBA, DCOM, Java RMI, .NET; newer ones include J2EE, WebSphere, Azure, Kubernetes, AWS Lambda.

Tiered architectures exam

Tiering is easy to confuse with layering, but the two work in different directions. Layering is a vertical organisation into levels of abstraction. Tiering takes the functionality within one layer, typically the application, and places it onto appropriate servers, which is a horizontal spread across machines. To tier an application, you first divide it into three kinds of logic:

  • Presentation logic handles user interaction and updates the view the user sees.
  • Application logic, also called business logic, implements what the application actually does (the rules of the business).
  • Data logic handles persistent storage, usually through a DBMS (database management system).
LAYERING · VERTICAL Application Middleware Operating system Hardware TIERING · HORIZONTAL (ONE LAYER, SPREAD OVER MACHINES) CLIENT Presentation view, user input APP SERVER Application business rules DB SERVER Data storage via DBMS three kinds of logic, each placed on an appropriate server
Layers stack up; tiers spread out. Take the highlighted application layer from the stack on the left and cut it into presentation, application and data logic; tiering decides which machine each piece runs on. Colours: blue = runs on the client, red = server, amber = database.

The two classic arrangements are two-tier and three-tier. They trade latency (the delay before a response) against maintainability (how easy the system is to change and keep running).

TWO-TIER CLIENT view controls some app logic SERVER rest of app logic data management one message exchange per operation but the logic is split across a process boundary THREE-TIER CLIENT view controls APP SERVER applogic DB SERVER data two links crossed per operation but each kind of logic lives in one place
Count the teal links. Two-tier answers each operation with one exchange (low latency) but splits the application logic between client and server. Three-tier puts each kind of logic on its own server (maintainable, thin clients possible) at the cost of an extra hop and three servers to manage.
Two-tierThree-tier
MappingApplication logic usually split between client and serverOne logical element per server
ProsLow latency: one message exchange per operationLogic in one place, so maintainable; clear roles; supports thin clients
ConsLogic split across a process boundary limits which parts can call whichThree servers to manage; extra traffic and latency per operation

Systems can also have more tiers, which is called multi-tier (or n-tier, or cascade). Wikipedia is built this way, and so is J2EE (Java 2 Enterprise Edition), where a request passes along a chain of four tiers.

TIER 1 TIER 2 TIER 3 TIER 4 browser presentation web server JSP, servlets EJB container business logic enterprise DBs data each tier is a separate server process; a request cascades left to right
Multi-tier: the same idea, more cuts. The web tier generates pages (JSP and servlets are Java technologies for that), the EJB container holds the business logic, and the databases hold the data.

AJAX

Standard web interaction has three problems. It blocks the user until a whole new page arrives; it re-sends a whole page even for a tiny change; and it cannot reflect changes on the server until the user reloads. AJAX (Asynchronous JavaScript And XML) fixes these by letting JavaScript code running in the browser request data from the server in the background, via the XmlHttpRequest object, and then update only part of the page. It is the glue between tier-1 (browser) and tier-2 (server) components. CDK illustrates it with a page of football scores.

AJAX: updating one score without reloading the page
browser JavaScript scores.php database 1 · Ajax.Request (one game) asynchronous: no waiting user keeps scrolling 2 · SQL query synchronous: server waits 3 · score 4 · HTTP response 5 · updateScore() Melb 2 – 1 Syd Bris 1 – 1 Perth only this line
  1. A web page shows several scores. Three participants: JavaScript running in the browser (blue), the server-side script scores.php (red), and the database (amber).
  2. The JavaScript sends an Ajax request for one game's score. The call is asynchronous: the browser does not wait, so the user keeps scrolling and clicking while the request is in flight.
  3. scores.php queries the database with SQL. This call is synchronous: the script needs the data before it can build its answer, so it waits.
  4. The database returns the score.
  5. scores.php sends the HTTP response back to the browser.
  6. The JavaScript function updateScore rewrites only that one line of the page. No full reload, no blocking.

Notice that the two calls behave differently, on purpose. The call from browser to server is asynchronous, because a delayed reply must not freeze the user interface. In three-tier designs the call from the server to the database is synchronous, because the server cannot continue without the data. Google Maps fetches its map tiles in the same way as the user drags the map.

Other patterns: proxy, brokerage, reflection

CLIENT HOST client deposit(10) proxy same interface SERVER HOST remote object same interface request
Proxy: the remote object's local stand-in. The client calls the proxy exactly as if it were the real object; the proxy forwards the call over the network. This gives location transparency.
service broker requester provider 1 publish 2 find 3 bind, invoke
Brokerage: a matchmaker. (1) Providers publish their services to the broker; (2) requesters find one there; (3) the requester then binds to the provider and invokes it directly. The Java RMI registry works this way.
  • Proxy. A local object with the same interface as a remote object forwards calls to it. This gives location transparency in RPC and RMI (Part VI), and a proxy can also encapsulate caching or replication behind that interface.
  • Brokerage. Three roles: a service provider, a service requester and a service broker that matches requests to providers. Examples are the Java RMI registry, the CORBA naming service and web-service registries.
  • Reflection. Combines introspection, which is discovering properties of a program at run time (for example, asking an object what methods its interface has), and intercession, which is modifying the program's structure or behaviour dynamically. Both work through a meta-level interface, a layer that describes the program itself. Java reflection, for example, is what lets RMI dispatch incoming calls generically: the server can invoke a method chosen by name at run time without code written for each method.
Check yourself"Layering and tiering are two names for the same idea." Explain why this is wrong.

Layering is a vertical organisation of a system into levels of abstraction (hardware, OS, middleware, applications), each using the one below. Tiering is horizontal: it takes the functionality within one layer (the application) and divides it into presentation, application and data logic placed onto appropriate servers. They are complementary: a three-tier application still runs on top of the layer stack on each machine.

Check yourselfIn the AJAX example, why is the browser-to-server call asynchronous but the server-to-database call synchronous?

The browser call is asynchronous so that a slow reply cannot freeze the user interface: the user keeps working and the page is patched when the data arrives. The server-to-database call is synchronous because the server cannot build its response until it has the data, so there is nothing useful to do while waiting.

Check yourselfThe Java RMI registry is an example of which pattern?
  1. Layering
  2. Proxy
  3. Brokerage
  4. Reflection

C, brokerage. Servers publish (bind) remote objects in the registry under names, and clients find them there, then invoke the objects directly. (The client then calls through a proxy, which is a different pattern used in the same system.)

In short
  • Layering is vertical: platform at the bottom, middleware hiding heterogeneity, applications on top.
  • Tiering is horizontal: presentation, application and data logic placed on servers. Two-tier = low latency; three-tier = maintainable, thin clients, but more hops and servers.
  • AJAX makes browser-to-server calls asynchronous; proxy, brokerage and reflection are further reusable patterns.
2.8

Middleware and Design Requirements

Middleware raises the level of programming abstraction and hides heterogeneity, and both aims serve one goal: interoperability (programs on different platforms can work together) and portability (a program can move to another platform unchanged). But how much can middleware really hide? This section sorts middleware into categories and then explains its limits.

Six categories of middleware

CDK Fig. 2.12 sorts middleware by the programming abstraction it offers. The categories overlap, since real platforms are hybrids, and besides its programming abstractions middleware also provides infrastructural services such as security and transactions.

Applications MIDDLEWARE Distributed objectsCORBA, Java RMI Distributed componentsEJB, CORBA Component Model, JBoss Publish-subscribeCORBA Event Service, JMS Message queuesWebSphere MQ, JMS Web servicesApache Axis, Globus Peer-to-peerPastry, Tapestry, Gnutella plus infrastructural services: security, transactions Operating system and hardware (the platform)
One layer, six programming models. Each card is a different abstraction offered to programmers; JMS appears twice because it supports both publish-subscribe and message queues, which shows how the categories overlap.

The limits of middleware: the end-to-end argument exam

End-to-end argument (Saltzer, Reed and Clark)

Some communication-related functions can be completely and reliably implemented only with the knowledge and help of the application at the end points of the communication. So the communication system on its own cannot fully provide them.

The classic example is transferring a very large email over TCP (the Internet's reliable stream protocol, Part III). TCP guarantees delivery while the connection lasts, but it cannot recover from a major network interruption that breaks the connection. Only the mail application knows how much of the message has been safely stored, so the mail service itself must record its progress and resume over a new connection.

The end-to-end argument: resuming a large email transfer
SENDER sending mail service very large email RECEIVER receiving mail service stored so far: progress log: 60% complete: 100% TCP connection 1 network interruption: connection 1 broken TCP alone cannot recover TCP connection 2: resume from 60%
  1. A sending mail service must deliver a very large email to a receiving mail service.
  2. It opens TCP connection 1 and starts sending. TCP masks lost and corrupted packets, and the receiving mail service records its own progress: 60% safely stored.
  3. A major network interruption breaks the connection. TCP cannot recover: the connection is simply gone, and TCP has no idea what the application has already saved.
  4. The mail application, which does know, opens TCP connection 2 and resumes from its recorded 60% instead of starting again.
  5. The transfer completes. Reliability for the whole transfer came from the end points, not from the communication layer.

Hence middleware cannot hide all communication concerns. Correctness needs checks at several levels, and the right behaviour for middleware depends on the application, which is what motivates adaptive middleware that can be tuned to each application's needs.

Design requirements (slides)

These requirements come from the slides; CDK 5th edition does not list them separately. They are the qualities an architecture is judged by.

Performance

Responsive, productive, balanced

Responsiveness matters for interactive clients and is helped by caching, replication and few layers. Throughput is the work done per unit time. Load balancing and timeliness come from multiple servers, DNS redirection, process migration and moving work to clients.
Quality of service

Beyond "it works"

Reliability, security and performance, plus adaptability to changing configurations. It also covers guarantees for time-critical data such as multimedia.
Caching and replication

The main tools

The chief means of improving performance and availability. Their cost is consistency: copies can disagree.
Dependability

Can you rely on it?

Correctness, security and fault tolerance: the system keeps working despite hardware, software and network faults, mainly through redundancy. The level needed depends on the domain: a website versus avionics.
Check yourselfState the end-to-end argument and give the textbook example.

Some communication-related functions can be completely and reliably implemented only with the knowledge and help of the application at the end points, so the communication system alone cannot provide them fully. Example: a very large email sent over TCP. TCP cannot recover from a major network interruption that breaks the connection, so the mail service records its progress and resumes over a new TCP connection. Therefore middleware cannot hide every communication concern.

Check yourselfWhich of these is not one of CDK's middleware categories?
  1. Distributed objects
  2. Message queues
  3. Thin clients
  4. Peer-to-peer

C. A thin client is a client-server variant (2.6), not a middleware category. The six categories are distributed objects, distributed components, publish-subscribe, message queues, web services and peer-to-peer.

In short
  • Middleware aims at interoperability and portability; its six categories are distributed objects, components, publish-subscribe, message queues, web services and P2P, plus infrastructural services.
  • The end-to-end argument: some functions need the application at the end points, so middleware cannot hide everything (the resumed email transfer).
  • Design requirements: performance, quality of service, caching and replication (at the cost of consistency), and dependability.
2.9

Fundamental Models: Interaction

The architectural models of the previous sections differ a great deal, but underneath they all consist of processes communicating by sending messages over a network. The fundamental models keep only that essence, so that we can reason precisely about what any distributed system can and cannot do. There are three: the interaction model (this section), the failure model (2.10) and the security model (2.11).

Purpose of a fundamental model exam
  1. To make all the relevant assumptions explicit about the systems being modelled.
  2. To make generalisations about what is possible or impossible under those assumptions, in the form of general-purpose algorithms, guaranteed properties and proofs.

A design can then be checked against a real system simply by asking whether the model's assumptions hold there.

What the interaction model describes

Processes interact by passing messages, and that gives two things: communication (information flows between processes) and coordination (processes synchronise and order their activities). The behaviour of the whole system is a distributed algorithm: a definition of the steps taken by each process, including the transmission of messages between them. Each process has its own private state (its variables), which no other process can read directly; the only way to learn about another process's state is to receive a message from it.

Two significant factors exam shape this interaction and make distributed algorithms hard: (1) communication performance is often a limiting factor, and (2) it is impossible to maintain a single global notion of time. We take them in turn.

Performance of communication channels exam

A channel is the path a message takes from one process to another. Three properties describe how well it performs.

p q m1 m2 m3 size ÷ bandwidth latency start of sending → start of receipt m1, m2 and m3 take different times to cross: that variation is jitter time →
Each message is a slanted band. The band's width at the sender is how long it takes to push the bits out (message size divided by bandwidth). The slant is the delay. Latency is measured to the first bits arriving; jitter is how much that delay varies from message to message.
  • Latency is the delay between the start of a message's transmission by one process and the beginning of its receipt by another. It includes the time for the first bits to reach the destination (long for a satellite link, for example), the network access delay, which grows as the network gets busier, and the operating system's communication processing at both ends.
  • Bandwidth is the total amount of information that can be transmitted over the network in a given time, such as 100 Mbps (megabits per second). It is shared by all the channels using the same network.
  • Jitter is the variation in the time taken to deliver a series of messages. It distorts audio and video playback: if successive video frames arrive at uneven intervals, the picture stutters.
A sense of scale

The lecturer's comparison: on a LAN you might wait 1–2 seconds for an acknowledgement before suspecting a problem, but for a message to Mars you would have to wait about 22 minutes. Any sensible timeout depends on the latency you expect.

Clocks and drift exam

Each computer has its own hardware clock, which it uses to timestamp events. Unfortunately, clocks drift away from perfect time, and different clocks drift at different rates.

Drift rate

The rate at which a clock deviates from a perfect reference clock. For ordinary quartz clocks it is about 10−6 seconds per second: roughly one second gained or lost every 11.6 days.

Skew

The difference between the readings of two clocks at the same instant (CDK §14.2).

real time → clock reading perfect clock fast clock: runs ahead slow clock t skew at t all three set equal at the start
Clocks set equal will diverge unless corrected. The slopes differ (that is drift), so the gap between any two clocks (the skew) keeps growing. The drift is hugely exaggerated here so you can see it.

So clocks that are set equal will diverge unless they are corrected. GPS receivers give about 1 µs accuracy, but not indoors and not cheaply. Otherwise a computer with an accurate clock can send time messages to the others, as NTP (the Network Time Protocol) does. But each time message takes a variable amount of time to arrive, so the receiver never knows exactly how old the time it was told is. As a result, no guaranteed bound on the difference between clocks is possible this way.

Synchronous versus asynchronous systems exam

The two factors above (unpredictable delays, unreliable time) are exactly what separates the two basic models of a distributed system. The question is whether anything about timing is guaranteed.

Synchronous system

One with known bounds on all three of: (1) the time to execute each step of a process (both lower and upper bounds); (2) the time to deliver a message; (3) the drift rate of each local clock.

Asynchronous system

One with no bounds on process execution speed, message transmission delay or clock drift rate. Anything may take arbitrarily long.

client server arrives in [min, max] request crash bound passed no reply within the bound ⇒ the server has certainly failed
Synchronous: a timeout is proof. Because delays are bounded, silence past the bound can only mean failure.
client server request ? no window: could arrive any time timeout crashed? overloaded? just delayed? only "not responding"
Asynchronous: a timeout is only a suspicion. With no bounds, a slow server and a dead one look identical.
SynchronousAsynchronous
Failure detectionTimeouts detect crashes reliablyA timeout means only "not responding": crashed, slow, or delayed?
RealismNeeds guaranteed CPU and network resources and bounded-drift clocksExactly models the Internet
SolvabilityMore problems solvable (e.g. multimedia deadlines)Any solution here also works in a synchronous system

You can always guess bounds, but a design that relies on bounds nobody guarantees is unreliable. Modelling a system as synchronous is still useful, because it tells you how the system is likely to behave. Real systems, though, are usually asynchronous, because processes share processors and channels share networks, so nothing stops a process or a message from being delayed by the others. Some problems are still solvable asynchronously: a browser lets the user get on with other things while a page loads, however long that takes. Others, such as delivering each multimedia frame before its deadline, need the synchronous model.

Two meanings of "synchronous"

Here, "synchronous system" means bounded timing. It has nothing to do with synchronous (blocking) calls in Part III, where the caller waits for an operation to finish. The speaker notes also use the word loosely for "real-time two-way communication"; in the exam, use the CDK definition above.

The Pepperland example

CDK makes this concrete with a story. Two divisions of the Pepperland army, Apple and Orange, are camped on two hills with the enemy in the valley between. They can win only if they charge together, and they must agree on who leads the charge and when. They communicate only by messengers who are reliable (never captured, in this version) but travel at variable speed.

Pepperland: who leads, and when to charge
Apple Orange troop counts larger leads (tie: Apple) → Apple Charge! could arrive at any time: no bound "when to charge" cannot be agreed send + min send + max Charge! Apple charges after waiting min received +1 min Orange charges Orange charges after Apple, at most (max − min + 1) min later
  1. Apple (green) and Orange (amber) each have a timeline; time runs right. Messengers always arrive, but nobody knows in advance how long they take.
  2. Each division sends its troop count to the other. However slow the messengers, both counts eventually arrive.
  3. Both apply the same rule: the larger division leads, and in a tie Apple leads. Suppose Apple is larger. Deciding who leads is therefore solvable even in an asynchronous system: it needs only eventual delivery, not timing.
  4. Now when? In an asynchronous system Apple's "Charge!" messenger could arrive at any time, so Apple cannot know when Orange will charge. Not solvable.
  5. In a synchronous system every messenger takes between min and max minutes (gold window). Apple sends "Charge!", waits min minutes, and charges.
  6. Orange charges 1 minute after receiving the message. Since it received the message at least min after sending, it charges after Apple, and at most (max − min + 1) minutes later. Timing is now guaranteed.

Event ordering exam

Often we need to know whether one event happened before, after or concurrently with an event at a different process. With no global clock, that is surprisingly hard. Consider a mailing list: X posts a message titled Meeting (m1); Y replies (m2); Z replies to both (m3). Because each message suffers its own independent delay, user A receives them in the order m3, m1, m2, so A sees replies before the message they answer.

X Y Z A m1 m2 m3 1 2 3 4 1st: m3 2nd: m1 3rd: m2 A sees the replies before the original gold numbers: Lamport timestamps
Delays scramble the order. m1 (blue) took the long way to A, so A received Z's reply m3 (green) first. The gold numbers show how logical time recovers order without clocks: each send and receive gets a larger number than anything that happened before it.

If the clocks were perfectly synchronised, each message could carry a timestamp, t1 < t2 < t3, and A could sort by them. Since that is impossible, Lamport's logical time infers the order from two facts that need no clocks: a message is always received after it is sent, and a reply is always sent after receiving the message it answers. Events are numbered so that later events always get larger numbers. In the example, X sends m1 at 1, Y receives m1 at 2, Y sends m2 at 3 and X receives m2 at 4. (The details are in CDK chapter 14.)

Check yourselfA client's request has had no reply for 10 seconds. In an asynchronous system, which conclusion is justified?
  1. The server has crashed.
  2. The network has lost the request.
  3. The server is not responding; it may have crashed, be slow, or the messages may be delayed.
  4. The server is fail-stopped.

C. In an asynchronous system there are no bounds on process speed or message delay, so a timeout cannot distinguish a crash from slowness or delay. A and B are possibilities, not conclusions. D is wrong because fail-stop means the failure can be detected with certainty, which needs a synchronous system.

Check yourselfDistinguish latency from jitter with a video-call example.

Latency is the delay from the start of sending a frame to the start of its receipt; high latency makes the conversation lag (you hear answers late). Jitter is the variation in that delay from frame to frame; high jitter makes frames arrive unevenly, so the picture and audio stutter even if the average delay is small.

Check yourselfWhy can't NTP give a guaranteed bound on the difference between two computers' clocks?

Because the time messages themselves suffer variable message delays. When a computer receives "the time is T", it cannot know exactly how long the message spent in transit, so it cannot know exactly how far its own clock is from T. Without a bound on message delay (an asynchronous system), there can be no bound on clock skew.

In short
  • Fundamental models make assumptions explicit and support generalisations about what is possible.
  • Channels are characterised by latency, bandwidth and jitter; clocks drift at different rates, so skew grows and no global time exists.
  • A synchronous system has bounds on step time, message delay and clock drift; an asynchronous one has none and models the Internet, where a timeout is only a suspicion.
  • Event order can be inferred with Lamport's logical time: send before receive, receive before reply.
2.10

The Failure Model

In a distributed system, both the processes and the communication channels can go wrong. To design anything that copes, you first need a precise vocabulary for how they can go wrong, because the remedy depends on the kind of failure. CDK classifies failures, following Hadzilacos and Toueg, into three groups: omission failures, arbitrary failures and timing failures.

Omission failures exam

In an omission failure, a process or channel fails to perform actions it is supposed to. It does not do anything wrong; it just fails to do something.

Process omission: crash and fail-stop

For a process, the basic omission failure is a crash: the process halts and executes no further steps, ever. Other processes try to detect crashes with timeouts: "if I hear nothing within T seconds, assume it has crashed". But, as 2.9 showed, in an asynchronous system a timeout only tells you the process is not responding. A fail-stop failure is a crash that other processes can detect with certainty. That is possible only in a synchronous system with guaranteed message delivery, where no reply within the bound really does mean the process has failed.

p q q halts ping bound passed process list: q gone others MAY detect it, with certainty
Fail-stop. q halts and stays halted, and p can be sure of it: in a synchronous system, silence past the bound proves failure. Like a process that has visibly vanished from ps or Task Manager.
p q stops responding still running? (zombie) ping timeout others MAY NOT be able to detect it
Crash. q also halts for good, but p cannot be sure: a crashed "zombie" may even still be running while it ignores messages. The only difference from fail-stop is certain detectability.

Communication omission: three places a message can vanish

Omissions also happen in communication. To send a message, process p puts message m into its outgoing buffer (memory managed by the operating system); the channel moves m to q's incoming buffer; and q then takes it from there. A message can be lost at each of these three steps, which gives three kinds of omission.

process p send(m) outgoing buffer COMMUNICATION CHANNEL incoming buffer process q receive(m) send-omission send completes, but m never enters the outgoing buffer channel omission m never reaches the incoming buffer: no buffer space at the receiver or a gateway, or a transmission error caught by a checksum receive-omission m is in the incoming buffer, but q never receives it
Where a message can be lost. Send- and receive-omissions are failures of the processes (their buffers are on their own hosts); a channel omission, informally "dropping messages", is a failure of the channel.

A checksum, mentioned in the figure, is a small value computed from a message's bytes and sent with it; the receiver recomputes it, and if the two disagree the message was damaged in transit and is thrown away.

Arbitrary (Byzantine) failures exam

Arbitrary failures are the worst possible failure semantics, because any error can occur. A process may produce wrong values or results, omit processing steps, or take extra steps it should not. They are also called Byzantine failures. Crucially, they cannot be detected by non-response, because the faulty process may still reply, or may arbitrarily choose to omit a reply.

ARBITRARY · PROCESS add(2, 2) faulty process skips or adds steps 5 wrong results, omitted or extra steps; it may still reply, so silence proves nothing ARBITRARY · CHANNEL p q #7 corrupted checksum fails: drop #7 again seq. no. seen: drop corrupt, spurious or duplicate messages: rare, because checksums and sequence numbers catch them
Anything can happen. A Byzantine process may return wrong answers that look perfectly normal. On channels, arbitrary failures are rare in practice because checksums catch corruption and sequence numbers (a counter carried in each message) catch duplicates.

The classification table exam

CDK Fig. 2.15 brings the omission and arbitrary failures together. Learn it as a table: for each class, what it affects and what happens. Notice that fail-stop and crash differ only in whether others can detect the failure.

Class of failureAffectsDescription
Fail-stopProcessProcess halts and remains halted. Other processes may detect this state.
CrashProcessProcess halts and remains halted. Other processes may not be able to detect this state.
OmissionChannelA message inserted in an outgoing message buffer never arrives at the other end's incoming message buffer.
Send-omissionProcessA process completes a send, but the message is not put in its outgoing message buffer.
Receive-omissionProcessA message is put in a process's incoming message buffer, but that process does not receive it.
Arbitrary (Byzantine)Process or channelProcess/channel exhibits arbitrary behaviour: it may send or transmit arbitrary messages at arbitrary times, commit omissions; a process may stop or take an incorrect step.

Timing failures exam

A timing failure occurs when a stated time bound is exceeded. Since only synchronous systems state time bounds, timing failures apply only to them. There are three classes.

allowed clock real time Clock · process local clock exceeds its drift bound bound actual gap between steps Performance · process exceeds bound between two steps p q should arrive too late Performance · channel transmission takes longer than bound
Gold is the promise, red is what happened. A clock drifting outside its allowed cone, a process taking too long between steps, and a message arriving after its deadline are all timing failures, but only because a bound was promised.
Class of failureAffectsDescription
ClockProcessProcess's local clock exceeds the bounds on its rate of drift from real time.
PerformanceProcessProcess exceeds the bounds on the interval between two steps.
PerformanceChannelA message's transmission takes longer than the stated bound.

In an asynchronous system, by contrast, a slow server has no timing failure, because nothing was ever promised. Timing failures have a high impact wherever lateness itself is the harm: in video conferencing and streaming, where late frames are useless; in real-time control such as avionics, car braking or industrial plants; and in trading systems. Real-time operating systems give timing guarantees, but general-purpose ones (Windows, Linux) do not.

Severity

Omission failures and timing failures are benign: something is missing or late, but nothing false is said. Arbitrary failures are the most severe, because a process may say false things that look true.

Failure detection and the impossibility of agreement

Pepperland illustrates failure detection too. Suppose the two divisions send each other regular status messengers ("still here"). In an asynchronous system, neither can tell whether the other has been defeated or its messenger is just slow. In a synchronous system, a missing messenger proves defeat, although the defeat may have happened at any time after the last messenger left.

Now make things worse: suppose messengers can be captured, so the channel can lose messages. The impossibility of agreement over lossy channels exam says that Apple and Orange then cannot guarantee to decide consistently, however clever their protocol. The stepper walks through the argument.

Why agreement over a lossy channel is impossible
Apple Orange 1 · attack at dawn? 2 · agreed 3 · got it 4 · got your ack decide: attack decide: attack the last message might be captured, so the decision cannot depend on it: remove it both decide with no messages at all: contradiction
  1. Imagine any protocol that lets Apple and Orange agree, say this one with four messages, after which both decide: attack. Messengers may be captured.
  2. Look at the last message (4). It might be captured, and Orange, who sent it, would never know. So both decisions must be the same whether or not message 4 arrives: the decision cannot depend on it, and it can be removed.
  3. Now message 3 is the last one. The same argument applies: it might be captured, so the decision cannot depend on it either. Remove it.
  4. Repeat for message 2.
  5. And for message 1.
  6. We are left with a protocol that reaches agreement using no messages at all, which is absurd for a decision that depends on the situation. That contradiction shows no protocol can guarantee consistent agreement over a lossy channel.

Masking failures exam

Knowing the failure classes lets us build reliable services from unreliable parts. A service masks a failure of one of its components either by hiding it completely or by converting it into a more acceptable type of failure.

CHECKSUM m garbled dropped corruption detected arbitrary → omission converted to a milder type RETRANSMISSION sender receiver resend omission hidden as TCP does REPLICATION client server 1 replica crash hidden another copy answers RESTART old process saved state new process crash recovered restored from disk
Four masks. Only the first converts a failure (arbitrary into omission); the other three hide one. Green shows the masking action.
  • Checksums turn an arbitrary failure (a corrupted message) into an omission, because the corrupted message is detected and discarded.
  • Retransmission hides omissions, as TCP does.
  • Replication hides a server crash.
  • A crashed process can be replaced and restored from state saved on disk.

Reliable one-to-one communication exam

"Reliable" is used loosely in everyday speech; here it has a precise two-part definition.

Validity

Any message in the outgoing message buffer is eventually delivered to the incoming message buffer.

Integrity

The message received is identical to one sent, and no message is delivered twice.

outgoing buffer incoming buffer validity integrity Reliable 1 2 3 1 2 3 yes yes Loses messages 1 2 3 1 3 NO yes Duplicates 1 2 3 1 2 2 3 yes NO
Reliable needs both columns. A channel that loses message 2 has integrity (nothing wrong or doubled arrives) but not validity; one that delivers 2 twice has validity but not integrity. Neither is reliable.

Integrity faces two threats. The first is retransmitting protocols that do not reject duplicates: if a sender resends a message whose acknowledgement was lost, the receiver may get it twice. The fix is sequence numbers, so the receiver can spot a number it has already seen. The second is malicious injection of spurious messages, replay of old ones, or tampering, which needs security measures (2.11).

Applying the failure model to a project

In a TCP client-server system such as Assignment 1, the failure model looks like this. The channels use TCP, which masks omission, duplication and corruption, so the channels can be treated as reliable while the connection lasts; a connection can still break, which shows up in Java as an IOException. Processes may crash, but they are not assumed to be Byzantine. And because the system is asynchronous, a socket timeout or a heartbeat (a periodic "I'm alive" message) can only suspect a failure. The client below shows this.

import java.io.*;
import java.net.*;

public class PingClient {
    public static void main(String[] args) throws IOException {
        try (Socket s = new Socket("localhost", 4444)) {      // connect to server
            s.setSoTimeout(2000);                              // block at most 2 s on a read
            PrintWriter out = new PrintWriter(s.getOutputStream(), true);
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(s.getInputStream()));
            out.println("PING");                               // request
            System.out.println("Reply: " + in.readLine());     // reply within the bound
        } catch (SocketTimeoutException e) {
            // Asynchronous system: the server is only NOT RESPONDING.
            // It may have crashed, be overloaded, or the reply may be delayed.
            System.out.println("Server suspected failed (not certain)");
        }
    }
}
  1. new Socket("localhost", 4444) opens a TCP connection to a server on this machine, port 4444. The try-with-resources form closes the socket automatically when the block ends.
  2. s.setSoTimeout(2000) sets a 2000 ms (2 s) timeout: any later read on this socket blocks for at most 2 s, then throws SocketTimeoutException. This is the client imposing its own bound on an unbounded system.
  3. The PrintWriter (with auto-flush true) and BufferedReader wrap the socket's byte streams so the client can write and read lines of text.
  4. out.println("PING") sends the request; in.readLine() blocks waiting for the reply line and prints it if it arrives within 2 s.
  5. If 2 s pass first, the catch block runs. The comment is the whole lesson: in an asynchronous system the client can only say the server is suspected failed, not that it has crashed.
PingClient server 1 · "PING" waits ≤ 2 s SocketTimeoutException "suspected failed (not certain)" ? the server crashed? the server is overloaded? the reply is delayed? all three look identical to the client
A timeout is a guess. After 2 s of silence the client knows only that no reply has arrived yet. Any of the three explanations on the right fits what it observed.
Check yourselfWhat exactly is the difference between a crash failure and a fail-stop failure, and what does fail-stop require of the system?

In both, the process halts and remains halted. In a fail-stop failure other processes can detect that it has halted, with certainty; in a crash they may not be able to. Certain detection requires a synchronous system with guaranteed message delivery, where no reply within the bound proves failure.

Check yourselfA web server in an ordinary (asynchronous) Internet system takes 30 seconds to answer a request. Is this a timing failure?
  1. Yes, a performance failure of the process
  2. Yes, a performance failure of the channel
  3. No, because no time bound was ever stated
  4. No, because it eventually replied

C. Timing failures are defined only relative to a stated bound, so they exist only in synchronous systems. In an asynchronous system a slow server has made no promise and so has not failed. D is a near-miss: replying eventually does not matter; what matters is that there was no bound to exceed.

Check yourselfA channel delivers every message exactly once, but occasionally flips a bit so the content is wrong. Which reliability property fails, and how would you mask the failure?

Integrity fails, because the message received is not identical to the one sent (validity holds: everything is delivered). Mask it with a checksum: corrupted messages are detected and discarded, converting the arbitrary failure into an omission, and retransmission then hides the omission, which is what TCP does.

Check yourselfClassify each: (a) a process's clock runs 1 s/hour fast in a system that promised 1 ms/hour; (b) a router drops packets because its buffer is full; (c) a server returns a wrong balance; (d) a process completes send but the message never enters its buffer.

(a) Clock (timing) failure of a process. (b) Channel omission: lack of buffer space at a gateway. (c) Arbitrary (Byzantine) failure of a process. (d) Send-omission, a process failure.

In short
  • Omission: crash (maybe undetectable) and fail-stop (detectable, needs synchrony); send-, channel and receive-omissions.
  • Arbitrary (Byzantine): anything, including plausible wrong answers; the most severe. Timing: clock and performance failures, synchronous systems only. Omission and timing failures are benign.
  • Masking hides failures or converts them to milder ones; reliable communication = validity + integrity.
  • Over lossy channels, agreement cannot be guaranteed.
2.11

The Security Model

The failure model assumed that things go wrong by accident. The security model assumes that someone is trying to make them go wrong. Because a distributed system is open (anyone on the network can send it messages), we need a precise picture of what an attacker can do, so that we can say what each defence protects against. Part X covers the mechanisms in depth; this section sets up the model.

The security model exam

Security in a distributed system is achieved by securing the processes and the channels used for their interactions, and by protecting the objects they encapsulate against unauthorised access.

Protecting objects

Objects are protected by checking who is asking against what they are allowed to do. Access rights specify who may perform which operations on an object: the owner of a private mailbox may read and delete its messages, while a shared web page may be readable by anyone. A principal is the authority on whose behalf an invocation is made or a result is issued; it may be a user or a process. The server is responsible for verifying the principal behind each invocation and checking its access rights, rejecting requests that are not allowed (for example by consulting an ACL, an access control list naming who may do what). The client, in turn, may check the principal behind the server, to be sure the result really came from the service it meant to use.

principal: user Alice client may verify the server's principal invocation (for Alice) result server 1 · who is the principal? 2 · allowed? if not, reject object: Alice's mailbox access rights (ACL) Alice: read, delete Bob: none
The server is the gatekeeper. For every invocation it asks two questions in order: who is this really for (the principal), and is that principal allowed to do this to this object (the access rights)?

The enemy exam

To reason about threats we assume an enemy (also called an adversary) with two powers. It can send any message to any process, and it can read or copy any message sent between processes. It can do this from any computer attached to the network, whether that computer is legitimately connected or not. This is deliberately pessimistic: a design that is safe against this enemy is safe against weaker ones too.

process p process q COMMUNICATION CHANNEL m enemy copy of m forged m′ can read or copy any message can send any message to anyone
The enemy's two powers. It sees every message (left) and can inject any message (right). Red means hostile throughout this Part.

This enemy gives rise to four kinds of threat.

THREATS TO PROCESSES client server spooferforged IP src Who really sent this? servers can't tell the principal; clients can't tell the real server THREATS TO CHANNELS pay $100 pay $100 pay $100 replayed copy, alter, inject, replay privacy and integrity at risk DENIAL OF SERVICE serveroverloaded client flood of pointless requests legitimate users locked out MOBILE CODE sandbox Trojan horselooks useful uses the host process's rights for other purposes so confine it
Four ways the enemy can hurt you. Note what each panel attacks: the identity of the processes, the messages in transit, the availability of the service, and the host that runs downloaded code.
  • Threats to processes. A receiver cannot be sure who sent a message, because IP source addresses can be forged. So a server cannot tell which principal sent an invocation, and a client cannot tell whether a result came from the real server or from a spoofer (an impostor pretending to be it).
  • Threats to channels. The enemy can copy, alter or inject messages, which threatens their privacy and integrity, or it can save messages and replay them later. Replaying a "transfer $100" message, for instance, would repeat the transfer.
  • Denial of service. The enemy sends excessive, pointless invocations or floods the network, overloading the bandwidth or the servers so that legitimate users cannot be served. An example is saturating the computer that controls a building's door locks.
  • Mobile code. Code that a host receives may be a Trojan horse: it looks useful, but uses the host process's access rights for other purposes. Hosts must be built carefully, for example by running such code in a sandbox.

Defeating the threats exam

Three techniques defeat these threats, and each builds on the one before.

  1. Cryptography and shared secrets. If a process can prove that it knows a secret shared only by itself and one other process, that identifies it as the sender. Encryption scrambles a message using a key, so that only someone holding the decryption key can recover the original.
  2. Authentication. The message includes an encrypted portion containing enough of the message to prove it is authentic. For example, a request to a file server can carry the principal's identity, the file ID and a timestamp, encrypted with a key shared only by the client and the file server. The server decrypts that portion and compares it with the rest of the request: if they match, only someone who knew the key could have made it.
  3. Secure channel. Encryption and authentication are combined to build a secure channel on top of an existing communication service. It has three properties: (1) each process reliably knows the principal behind the other; (2) the data keeps its privacy and integrity; and (3) each message carries a physical or logical timestamp, which stops it being replayed or reordered. VPNs and SSL/TLS are examples (Part X).
principal "Alice" fileID which file timestamp when sent operation e.g. read(block 7) {principal, fileID, timestamp}KCS encrypted with the client–server key server decrypts this and compares it with the plain fields: a match proves who sent it
Authentication by encrypted portion. Anyone can forge the plain fields, but only a holder of KCS can produce a matching encrypted portion. The timestamp inside it also stops an old request being replayed.
process p acting for Alice process q the file service secure channel 1 each knows the principal behind the other 2 privacy and integrity 3 timestamps stop replay and reordering sees only ciphertext; a replayed message is rejected enemy
Three guarantees in one pipe. Each numbered property defeats one family of threats: (1) spoofing of processes, (2) copying and tampering on the channel, (3) replay and reordering.
A caution about the speaker notes

The speaker notes say secure-channel traffic is "encrypted by the sender with their private key" and decrypted with the sender's public key. That actually describes a digital signature, which gives authenticity but not secrecy: anyone holding the public key could read the message. TLS really uses public-key cryptography to authenticate the parties and agree a shared session key, and then encrypts the data with that session key (Part X). Do not repeat the speaker notes' version in the exam.

Security has a price in processing and management effort. So the sensible approach is to build a threat model, a list of all the forms of attack with their risks and consequences, and to balance the cost of each countermeasure against the risk it removes.

Check yourselfWhich capability is not assumed of the enemy in the CDK security model?
  1. Sending any message to any process
  2. Reading or copying any message between processes
  3. Acting from any computer connected to the network, legitimately or not
  4. Reading the private memory of the server process

D. The enemy works on the network: it can send any message and read or copy any message, from any connected computer. Reading a process's private memory is not one of the enemy's assumed powers.

Check yourselfAn attacker records a valid "transfer $500 to Bob" message and sends it again an hour later. Which threat is this, and which property of a secure channel defeats it?

It is a replay, a threat to channels. It is defeated by property (3) of a secure channel: each message carries a physical or logical timestamp, so the receiver recognises the old message and rejects it. (Encryption alone would not help: the attacker never needed to read the message, only to resend it.)

Check yourselfWhat is a principal, and what two checks does a server make on each invocation?

A principal is the authority (a user or a process) on whose behalf an invocation is made or a result issued. The server (1) verifies the identity of the principal behind the invocation and (2) checks that principal's access rights for the requested operation on the object, rejecting it if they are not sufficient.

In short
  • Security = securing processes and channels, and protecting objects via access rights checked against authenticated principals.
  • The enemy can send any message and read or copy any message. Threats: to processes (spoofing), to channels (copy, alter, inject, replay), denial of service, mobile code (Trojan horses).
  • Defences build up: cryptography and shared secrets → authentication → secure channels (known principals, privacy and integrity, timestamps against replay). Balance cost against risk with a threat model.
2.12

Exam Practice and Tutorial 5

This section collects the common mistakes, the real past-exam questions on this topic, a full self-test, and the official Tutorial 5 answers. Try each question before opening the answer.

Common pitfalls that lose marks
  • Client and server are roles, so one process can be both.
  • Layering (vertical abstraction) is not the same as tiering (placing an application's functions on servers).
  • The difference between crash and fail-stop is certain detectability, and that needs a synchronous system.
  • Timing failures exist only in synchronous systems.
  • "Synchronous system" here means bounded timing, not blocking calls (Part III). The speaker notes use the term informally for "real-time two-way communication"; in the exam, use the CDK definition.

Past exam questions (2016) exam

How these are marked

Answer exactly what is asked. "Give three reasons" means three different reasons, each explained in a sentence; "briefly explain three aspects" wants each aspect named and defined. Where a question asks for an example, make it concrete and say why it fits. The model answers below are the guide's.

2016 Q1(b) · 5 marksGeneral-purpose applications (e.g. a spreadsheet) are provisioned in the cloud and used through a web browser. Which architectural model best describes this, and why? Give three reasons supporting it, and an application for which it is unsuitable.

Model: client-server with thin clients, in the form of a cloud-hosted, multi-tier service. The browser handles only presentation, while the application logic and data run on remote cloud servers.

Reasons (any three):

  • installation, upgrades and backups are done centrally;
  • it works on any device with a browser, from anywhere;
  • clients need little CPU or storage;
  • shared data enables collaboration;
  • cloud servers scale elastically with demand, through replication and load balancing;
  • security administration is centralised.

Unsuitable for: highly interactive, latency-sensitive graphics (CAD, image or video editing, fast-action games), apps that must work offline, and hard real-time control, because network latency and jitter make the response unacceptable.

2016 Q3(a) · 3 marksBriefly explain three fundamental aspects of a communication channel important to a distributed system.
  • Latency is the delay from the start of transmission to the start of receipt, made up of propagation time, network access delay and OS processing. It limits responsiveness and affects the choice of timeouts.
  • Bandwidth is the amount of data that can be transmitted per unit time, and it is shared by all channels on the network. It limits throughput.
  • Jitter is the variation in delivery time of successive messages, and it harms multimedia and real-time streams.
2016 Q3(b) · 2 marksWhat is a timing failure? Give an example where it would have significant impact.

A timing failure is the exceeding of a stated time bound in a synchronous system: a clock drifting beyond its bound, a process step taking too long, or a message taking longer than its bound.

Example: video conferencing, where frames that arrive late are useless and the audio breaks up; or an aircraft or vehicle control system missing a deadline.

2016 Q2(b)-styleState the failure model of a simple multi-threaded TCP client-server system (e.g. Assignment 1).
  • Channels: TCP masks omission, duplication, reordering and corruption, so validity and integrity hold while connected. A connection may still break, raising an IOException, and there is no automatic reconnection.
  • Processes: subject to crash failures of the client or server. No Byzantine behaviour is assumed, though malformed requests are rejected rather than crashing the server.
  • Timing: the system is asynchronous, so timeouts or heartbeats can only suspect a crash.
  • Recovery: if the server crashes, completed writes have been persisted and are restored on restart. If a client crashes, the server closes that socket and frees the thread.

Self-test

Q5Name and define the three types of system model.
  1. A physical model describes the hardware nodes and networks, abstracted from specific technology.
  2. An architectural model describes the components' tasks, their placement and their relationships, as in client-server or P2P.
  3. A fundamental model gives a formal description of the properties common to all architectures: interaction, failure and security.
Q6Compare client-server and peer-to-peer.

Client-server is asymmetric and allocates responsibility statically, which keeps management simple and central. Its weaknesses are limited scalability and a single point of failure.

Peer-to-peer is symmetric and allocates responsibility dynamically, so capacity grows with the number of users, and because objects are replicated there is no central point of failure. The price is complexity, and security and availability are harder to achieve.

Q7Describe the four placement strategies.
  1. Multiple servers provide one service by partitioning objects (as the Web does) or replicating them (as NIS does), which improves performance and availability.
  2. Caching keeps recently used objects near clients, in the browser or a proxy, which lowers latency and load.
  3. Mobile code, such as an applet, runs at the client, giving responsiveness and push updates, but it needs a sandbox.
  4. Mobile agents are programs that visit resources carrying their data. They reduce communication but raise security issues for both the host and the agent.
Q8Define a mobile agent. How does it differ from mobile code, and why is its use limited?

A mobile agent is a running program (code and data) that travels between computers performing a task for someone, and returns with the results. It differs from mobile code such as an applet, which is downloaded once and runs at the client; an agent instead migrates from host to host with its state.

Its benefit is that it replaces remote invocations with local ones. Its use is limited because hosts must protect their resources from it, which means authenticating whom it acts for; because the agent itself can be refused access or tampered with; and because the same tasks can be done by remote invocation.

Q9Describe the three generations of distributed systems.
  1. Early systems had 10–100 homogeneous nodes on a LAN. Openness was not a priority, and QoS was in its infancy.
  2. Internet-scale systems are global and cross organisations. Their significant heterogeneity led to open standards, middleware and QoS services.
  3. Contemporary systems add mobile nodes (which move and need discovery), ubiquitous nodes (embedded in objects) and cloud nodes (pools of nodes). They are ultra-large, openness and QoS have become research challenges, and they include systems of systems.
Q10Compare two-tier and three-tier architectures.

Both divide an application into presentation, application and data logic. A two-tier architecture needs one message exchange per operation, which gives low latency, but its application logic is split across processes. A three-tier architecture keeps the logic in one place, which makes it maintainable, and it gives clear roles and supports thin clients. The cost is three servers to manage, and extra latency and traffic.

Q11Define middleware and explain the end-to-end argument with an example.

Middleware is software that masks heterogeneity and provides a convenient programming model, such as RMI or CORBA. The end-to-end argument says that some functions need application knowledge at the end points, so the communication layer cannot fully provide them. For example, a large mail transfer resumes on a new TCP connection after a major interruption.

Q12Define synchronous and asynchronous systems; what does the Internet's nature imply for failure detection?

A synchronous system has known bounds on process step time, message delay and clock drift, whereas an asynchronous system has no bounds. The Internet is asynchronous, so timeouts cannot distinguish crashed processes from slow ones or from delayed messages, and fail-stop detection is impossible.

Q13Why can't physical clocks order events perfectly, and how can order be inferred?

Physical clocks drift at different rates, so the skew between them grows, and synchronisation is limited by variable message delays. Order can instead be inferred logically, since a send precedes its receive and a receive precedes the reply to it. Lamport logical timestamps are built on this.

Q14Classify failures and explain masking.

Failures are classified as omission failures (crash, fail-stop, and send, channel and receive omission), arbitrary or Byzantine failures, and timing failures (clock and performance). Masking hides a failure or converts it into a more benign one. Checksums convert an arbitrary failure into an omission, retransmission hides omissions, replication hides crashes, and a process can be restarted from saved state.

Q15Define reliable communication and the threats to integrity.

Reliable communication has validity, meaning outgoing messages are eventually delivered, and integrity, meaning each message is identical to what was sent and there are no duplicates. Integrity is threatened by retransmission that delivers duplicates, which is fixed with sequence numbers, and by malicious injection, replay and tampering, which is fixed with secure channels.

Q16Describe the security model's enemy, threats and defences.

The enemy can send any message and can read or copy any message. The threats are forged identities (of servers and of clients), the copying, altering, injecting and replaying of messages, denial of service, and mobile code. The defences are access rights checked against authenticated principals, cryptography, authentication, and secure channels, which give principal identity, privacy and integrity, and timestamps against replay.

Tutorial 5 (Week 6): official answers official

These are the tutors' official answers posted on Ed (Tutorial 05, Week 6). Staff have confirmed tutorial content is examinable, so learn these definitions as given.

T5-1Briefly explain the difference between a client-server and a peer-to-peer architecture.

In a client-server architecture, a client requests processing or information that it needs from a server. The client waits in a blocking fashion for the reply containing the result, then carries on with its own execution. There are many variants (2.6).

A peer-to-peer architecture suits ad-hoc groupings of participants. There is no central point of failure, so it is reliable, and no central point of control, so it is hard for an adversary to deny service. Some peers typically contribute more than others (seeds, super-peers). Examples are Napster and BitTorrent.

T5-2Briefly explain each architecture variation, giving a reason or benefit for its use.

The tutors answered with the CDK figures. The definitions below are theirs; where their slides only showed a figure, the benefit is taken from CDK and 2.6.

  • Services provided by multiple servers. Several server processes interact to provide one service. Objects are partitioned across them (for example, web servers) or replicated (for example, Sun NIS). Benefit: scalability and reliability: the load is shared, and the service survives one server failing.
  • Proxy servers and caches. A cache is a store of recently used objects that is closer to the client. New objects are added, replacing existing ones. On a request, the cache is checked for an up-to-date copy, which is fetched if none is available. Benefit: lower latency for clients, and less load on servers and the wide-area network.
  • Mobile code and mobile agents. Mobile code is downloaded to the client and executed there (applets, for example). Mobile agents are running programs, both code and data, that travel from one computer to another. Benefit: mobile code gives responsive interaction because it runs locally, and an agent cuts communication by doing its work where the data is.
  • Network computers download their OS and application software from a remote file system, and the applications run locally. Benefit: central management and upgrades, and users can work at any machine.
  • Thin clients. Application software is not downloaded but runs on the compute server (UNIX, for example); the client only presents the UI. Benefit: cheap, low-power devices get powerful services, and administration is central. However, thin clients are usually not suitable for highly interactive graphical activities.
  • Tiered architecture. Tiering is complementary to layering: layering organises services vertically, while tiers spread an application's functions across machines. In two-tier, the client handles view, controls and data manipulation, and the server handles application and data management. In three-tier, the user view and controls are on the client, application logic is on an application server, and a database manager is on a database server. Benefit: each tier can be developed, scaled and maintained independently.

Ed practice quiz (Week 6)

The questions are from the Ed practice quiz; the answers are the guide's worked answers.

Practice 1Devices share files directly with no central server, and the rest carry on if half go offline. Which architecture?

Peer-to-peer: there is no central point of failure or control.

Practice 2DNS runs on many servers, each holding part of the data and cooperating to answer queries. Which variant?

A service provided by multiple servers: the data is partitioned or replicated, which improves reliability and scalability.

Practice 3The browser keeps local copies of images and refetches only if a copy might be outdated. Which variant?

Proxy server / caching.

Practice 4Terminals with no storage or OS; all applications run on a central UNIX server. What is this a poor fit for?

This is a thin client, so it is a poor fit for highly interactive graphical applications such as video editing, because of network latency.

Practice 5Browser, application server and database server as three tiers. What is the advantage over two-tier?

Each tier can be developed, scaled and maintained more independently.

In short
  • Past exams on this topic ask for an architecture with reasons and a counter-example (thin clients), the three channel properties (latency, bandwidth, jitter), timing failures, and a project's failure model.
  • Know the official Tutorial 5 definitions of each variant word for word, each paired with its benefit.