chapter 4 communication2. the client stub builds a message and calls the local operating system. 3....

42
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S. TANENBAUM MAARTEN VAN STEEN Chapter 4 Communication

Upload: others

Post on 21-Feb-2021

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

DISTRIBUTED SYSTEMS

Principles and Paradigms Second Edition

ANDREW S. TANENBAUM

MAARTEN VAN STEEN

Chapter 4

Communication

Page 2: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Layered Protocols (1)

Figure 4-1. Layers, interfaces, and protocols in the OSI model.

Page 3: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Layered Protocols (2)

Figure 4-2. A typical message as it appears on the network.

Page 4: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Middleware Protocols

Figure 4-3. An adapted reference model

for networked communication.

Page 5: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Types of Communication

Figure 4-4. Viewing middleware as an intermediate (distributed)

service in application-level communication.

Page 6: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

1) Client/Server computing is generally based on a model of

transient synchronous communication: • Client and server have to be active at time of communication.

• Client issues request and blocks until it receives reply.

• Server essentially waits only for incoming requests, and subsequently

processes them

• Drawbacks of synchronous communication:

• Client cannot do any other work while waiting for reply.

• Failures have to be handled immediately: the client is waiting.

• The model may simply not be appropriate (mail, news)

2) Message-oriented middleware: Aims at high-level persistent

asynchronous communication: Processes send each other

messages, which are queued • Sender need not wait for immediate reply, but can do other things Middleware

often ensures fault tolerance

Types of Communication

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Page 7: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Conventional Procedure Call

Figure 4-5. (a) Parameter passing in a local procedure call: the

stack before the call to read. (b) The stack while the called

procedure is active.

Page 8: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Basic RPC Operation

Figure 4-6. Principle of RPC between a client and server program.

Page 9: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

RPC Operation

Figure 4-7. The steps involved in a doing a

remote computation through RPC.

Page 10: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Remote Procedure Calls (1)

A remote procedure call occurs in the following

steps:

1. The client procedure calls the client stub.

2. The client stub builds a message and calls the local

operating system.

3. The client’s OS sends the message to the remote OS.

4. The remote OS gives the message to the server stub.

5. The server stub unpacks the parameters and calls the

server.

Continued …

Page 11: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Remote Procedure Calls (2)

A remote procedure call occurs in the following

steps (continued):

6. The server does the work and returns the result to the

stub.

7. The server stub packs it in a message and calls its local

OS.

8. The server’s OS sends the message to the client’s OS.

9. The client’s OS gives the message to the client stub.

10. The stub unpacks the result and returns to the client.

Page 12: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Passing Value Parameters (2)

Figure 4-8. (a) The original message on the Pentium.

Page 13: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Passing by Reference

• Like passing a pointer or an array or by reference.

• The pointer or address has meaning within the same

address space.

• Call by reference is replaced by a copy/restore.

• Difference between input and output parameters.

• A remote reference mechanism enhances access

transparency

• Remote reference offers unified access to remote data

• Remote references can be passed as parameter in RPCs

• Note: stubs can sometimes be used as such references

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Page 14: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Parameter Specification

and Stub Generation

Figure 4-9. (a) A procedure. (b) The corresponding message.

Page 15: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Asynchronous RPC (1)

Figure 4-10. (a) The interaction between client and

server in a traditional RPC.

Page 16: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Asynchronous RPC (2)

Figure 4-10. (b) The interaction using asynchronous RPC.

Page 17: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Asynchronous RPC (3)

Figure 4-11. A client and server interacting through

two asynchronous RPCs.

Page 18: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Writing a Client

and a Server (1)

Figure 4-12. The steps in writing a client and

a server in DCE RPC.

Page 19: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Writing a Client and a Server (2)

Three files output by the IDL compiler:

• A header file (e.g., interface.h, in C

terms).

• The client stub.

• The server stub.

Page 20: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Binding a Client to a Server (1)

• Registration of a server makes it possible for

a client to locate the server and bind to it.

• Server location is done in two steps:

1. Locate the server’s machine.

2. Locate the server on that machine.

Page 21: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Binding a Client to a Server (2)

Figure 4-13. Client-to-server binding in DCE.

Page 22: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Berkeley Sockets

Figure 4-14. The socket primitives for TCP/IP.

Page 23: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

The Message-Passing Interface (1)

Figure 4-15. Connection-oriented communication

pattern using sockets.

Page 24: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Making sockets easier to work with • Sockets are rather low level and programming mistakes are

easily made. However, the way that they are used is often the

same (such as in a client-server setting).

• ZeroMQ Provides a higher level of expression by pairing

sockets: one for sending messages at process P and a

corresponding one at process Q for receiving messages.

• All communication is asynchronous.

• Three patterns

1. Request-reply

2. Publish-subscribe

3. Pipeline

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Page 25: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

The Message-Passing Interface (2)

Figure 4-16. Some of the most intuitive

message-passing primitives of MPI.

Page 26: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Message-Queuing Model (1)

Figure 4-17. Four combinations for loosely-coupled

communications using queues.

Page 27: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Message-Queuing Model (2)

Figure 4-18. Basic interface to a queue in a

message-queuing system.

Page 28: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

General Architecture of a Message-

Queuing System (1)

Figure 4-19. The relationship between queue-level addressing

and network-level addressing.

Page 29: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

General Architecture of a Message-

Queuing System (2)

Figure 4-20. The

general organization of

a message-queuing

system with routers.

Page 30: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Message Brokers

Figure 4-21. The general organization of a message broker

in a message-queuing system.

Page 31: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

IBM’s WebSphere MQ

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Page 32: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

IBM’s WebSphere MQ

Figure 4-22. General organization of IBM’s message-queuing

system.

Page 33: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Channels

Figure 4-23. Some attributes associated with

message channel agents.

Page 34: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Figure 4-24. The general organization of an MQ queuing network using routing tables and aliases.

• By using logical names, in combination with name resolution to local

queues, it is possible to put a message in a remote queue

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Message Transfer (1)

Page 35: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Message Transfer (2)

Figure 4-25. Primitives available in the

message-queuing interface.

Page 36: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Application-level multicasting

• To do multicast: two forms are either building an overlay

network or using epidemic behavior.

• To overcome multicast routing usually an overlay network is

formulated.

• There are two main types of overlay multicast networks:

• 1- tree based where there will be a single path between every two

nodes in the multicast group

• 2- mesh based where there will be multiple paths between every two

nodes in the group. More robust, requiring a form of routing

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Page 37: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Overlay Construction

• Link stress: How often does an ALM message cross the same physical

link? Example: message from A to D needs to cross hRa;Rbi twice.

• Stretch: Ratio in delay between ALM-level path and network-level path.

Example: messages B to C follow path of length 73 at ALM, but 47 at

network level ) stretch = 73/47.

Page 38: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Flooding • Assume that an overlay network is built per multicast group. Then send a

message m to the set of destination is converted to flooding.

• Flooding in tree is optimal O(M)= N-1

• For fully connected network which has O(N2) = N*(N-1)/2 links.

• If each link exists with probability (none-structured overlay network) Pedge

number of links = Pedge * N * (N-1)/2.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Page 39: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Epidemic (Gossiping)

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Page 40: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Anti-entropy

• Anti-entropy propagation model

– Node P picks another node Q at random

– Subsequently exchanges updates with Q

• Approaches to exchanging updates

– P only pushes its own updates to Q

– P only pulls in new updates from Q

– P and Q send updates to each other (push-pull)

Page 41: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Rumor Spreading • A server S having an update to report, contacts other servers. If a server

is contacted to which the update has already propagated, S stops

contacting other servers with probability pstop. It become removed node.

• Fast propagation. But, no guarantee that the message will be delivered to

all nodes.

• Assume s is the fraction of nodes which will not receive updates.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

Page 42: Chapter 4 Communication2. The client stub builds a message and calls the local operating system. 3. The client’s OS sends the message to the remote OS. 4. The remote OS gives the

Deleting values

• Removal has to be registered as a special update by inserting

a death certificate.

• When to remove a death certificate (it is not allowed to stay

for ever)

• Run a global algorithm to detect whether the removal is known everywhere,

and then collect the death certificates (looks like garbage collection)

• Assume death certificates propagate in finite time, and associate a maximum

lifetime for a certificate (can be done at risk of not reaching all servers)

• It is necessary that a removal actually reaches all servers.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5