0% found this document useful (0 votes)
85 views60 pages

RPC

RPC allows a program to request a service from a program located in another address space. It uses stubs and a runtime system to hide the details of calling a remote procedure. The client stub packs arguments into a call message. The server stub unpacks the arguments and calls the procedure, then packs the result into a reply message. Marshalling encodes arguments and results for transmission. Servers can maintain client state (stateful) or not (stateless). Clients locate servers through interfaces and either broadcasting or a binding agent.

Uploaded by

Milind Shah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views60 pages

RPC

RPC allows a program to request a service from a program located in another address space. It uses stubs and a runtime system to hide the details of calling a remote procedure. The client stub packs arguments into a call message. The server stub unpacks the arguments and calls the procedure, then packs the result into a reply message. Marshalling encodes arguments and results for transmission. Servers can maintain client state (stateful) or not (stateless). Clients locate servers through interfaces and either broadcasting or a binding agent.

Uploaded by

Milind Shah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 60

2.

Remote Procedure Call (RPC)

What Is RPC ??
RPC is a powerful technique for constructing distributed, client-server based applications. It is based on extending the notion of conventional, or local procedure calling, so that the called procedure need not exist in the same address space as the calling procedure.

2.1 Introduction
RPC is a protocol that one program can use to request a service from a program located in another comp
RPC is an IPC technology that allows a program to cause a procedure to execute in another address space. When this mechanism is implemented using object-oriented principles, it is called Remote Method Invocation (RMI) RPC is a popular way of implementing client-server model of Distributed Computing where, Requesting program is a Client Service providing program is a Server RPC is used by both, an O.S. & by applications.. NFS is implemented as a set of RPCs DCOM , CORBA, Java RMI are RPCs 3

RPC is an extension of procedure call mechanism


It enables a call to be made to a procedure that does not reside in the address space of the calling procedure The called procedure (remote) can be on the same computer as that of the calling procedure or on a different computer In this case, as the caller and callee processes have different address spaces , there is no shared data Hence, RPC uses message passing scheme for communication.
4

Caller (Client)

Callee (Server)

Caller Proc blocked

Proc
executes

Resume Exec.
5

Issues in Transparency..

A transparent RPC mechanism is the one in which, local procedure and remote procedure are indistinguishable to the user.

2.2 Implementation of RPC


Implementation of RPC is based on concept of STUBs Which provide a normal procedure call abstraction by concealing from programs the interface to the underlying RPC system. RPC involves two processes : Client & Server A separate stub process is associated with each of the two processes Also, to hide the existence and functional details of the underlying network, RPC communication package called RPC Runtime is used on both the sides.
7

Elements involved in implementation of RPC Mechanism :


The Client The Client Stub RPC Runtime The Server Stub The Server

Client
Return Call Call

Server
Return

Client stub Unpack Pack

Server stub Unpack Pack

RPC Runtime

RPC Runtime

Receive

Send

Receive

Send

Client :
A user process that initiates a remote procedure call

Client Stub :
Responsible for two jobs : On receipt of a request call from client, It packs specifications of the target procedure & arguments into a message Then asks the local RPC Runtime routine to send it to the server stub On receipt of result of procedure execution, it unpacks the result and passes it to the client.
10

RPC Runtime:
Responsible for transmission of messages across the network between the client and server. On Client Machine - It receives a call request message from the client stub & sends it to the server machine. It also receives message containing result of procedure execution from server machine & passes it to the client stub. On Server Machine - It receives message containing the result of procedure execution from server stub & sends it to the client machine. It also receives call request message from the client machine & passes it to the server stub.

11

Server Stub :
Responsible for two jobs :
On receipt of a request call message from local RPC runtime,
It unpacks it and makes a normal call to invoke appropriate procedure in the server.

On receipt of result of procedure execution,


it packs the result into a message and then asks the local RPC Runtime to send it to the client stub.

Server :
It executes appropriate procedure & returns result of procedure execution to the server stub

12

13

14

15

2.3 RPC Messages :


Types of messages involved in implementation of RPC :

Call Messages: sent by client to server requesting execution of a remote procedure


Reply Messages: sent by server to client for returning result of remote procedure execution

16

1. Call Messages:
Components of a call message : Identification information of the remote procedure to be executed i.e. Remote procedure identifier. The arguments necessary for execution of the procedure Additional Fields: Message identification field : has a sequence no. for identifying lost messages and duplicate messages. Client identification field : to allow the server to identify the client.

17

Message Type field : used to distinguish call message from reply message 0 call message 1 reply message

RPC call message format:

18

2. Reply Messages:
When the server of an RPC receives a call message, it could be faced with one of the following conditions:

Call message violates RPC protocol

Action: Server rejects such a call.


Server detects by scanning clients id. Finds that it is not authorized to use the service Action: Server returns an unsuccessful reply. Remote procedure specified in the remote procedure id. Field of the call message is not available with it Action: Server returns an unsuccessful reply.
19

An exception condition (Division by zero) occurs during execution of remote procedure Action: Server returns an unsuccessful reply.
The specified procedure is executed successfully Action: Successful reply.

20

Fields in the Reply Message :


Message Identifier Field : same as call message. Message Type :Indicates it is a reply message. Reply status : 0 Successful reply 1 / non-zero value Unsuccessful reply Result : Result of procedure execution. Reason : Reason for failure
21

A successful reply message:

An unsuccessful reply message:

22

2.4 Marshalling arguments and results:


Implementation of RPC involves
transfer of arguments from the client process to the server process and, Transfer of results from server process to client process.

These arguments and results are transferred in form of message data between two computers.

In RPC, packing parameters into a message is known as marshalling

23

Steps in Marshalling :
1. Taking arguments (of client) or result (of server) that will form message data to be sent to remote process.
2. Encoding the message data. 3. Decoding the message data.

For successful marshalling, the client & server ,both should know the methods used.
24

2.5 Server Implementation :


Based on the style of implementation used, servers can be of two types: Stateful servers

Stateless servers

25

Stateful server: A stateful server maintains the clients state information from one remote procedure call to the next.
i.e. in case of two subsequent calls, some state info. related to service performed for the client as a result of first service call execution is stored by the server process. This clients state information is subsequently used at the time of execution of second call
26

Stateless server: A stateless server does not maintain any client state information. Hence, every request from the client MUST be accompanied with all necessary parameters to successfully carry out the desired operation. Server doesnt keep track of any information resulting from previous operation.client has to keep the track

27

Advantage of Stateful over stateless server:

They relieve the clients from keeping track of the state information

28

Advantage of Stateless over stateful:


They have an advantage in terms of failure. E.g. with stateful server, if the server crashes, & then restarts, the state information that it was holding may be lost and, client process might continue its task unaware of the crash, producing unwanted results. Hence, the client of a stateful server should be designed to detect server crashes , to do necessary error handling. Whereas, with stateless, a client has to only retry a request until the server responds; it does not need to know that the server has crashed. The choice is purely APPLICATION DEPENDENT.
29

2.6 Client-Server Binding: It is necessary for a client to know the location of a server before a remote procedure call can take place between them. The process by which a client becomes associated with a server so that calls can take place is known as Binding

30

Issues in Client-server binding process:


How does a client specify a server to which it wants to get bound? How does the binding process locate the specified server ? When is it proper to bind a client to a server? Is it possible for a client to change a binding during execution ? Can a client be simultaneously bound to multiple servers that provide the same service ?

31

2.6.1 How does a client specify a server to which it wants to get bound?
Server Naming : The specification of a client by a server with which it wants to communicate is a naming issue. Solution.Use of Interface. Two parts of Interface name: Type Instance.

32

2.6.2 How does the binding process locate the specified server ? Server Locating : When a client specifies the interface name of a server for making a RPC, the server must be located before the clients request message can be sent to it. Two methods:
Broadcasting Binding Agent

33

Broadcasting:
In this method, a message to locate the desired server is broadcast to all the nodes The nodes on which the desired server is located return a response message The desired server may be replicated on several nodes, so the client node will receive a response from all these nodes. Normally, the first response that is received at the clients node is given to the client process & all the subsequent responses are discarded

34

Advantage: Easy to implement Suitable for small networks Disadvantage:


Expensive for large networks.because of the increase in message traffic due to involvement of all nodes in the broadcasting process.

35

Binding Agent: It is a name server used to bind a client to a server by providing the client with the location information of the desired server. A binding agent maintains a binding table , which is mapping of a servers interface name to its locations. All the servers register themselves as a part of their initialization process. To register with the binding agent, a server gives the binder its identification information& a handle used to locate it.
36

A server can also deregister with the binding agent when it is no longer prepared to offer service. The binding agent can even poll the servers periodically , automatically deregistering any server that fails to respond

37

Locating process: To locate a server, a client contacts the binding agent..lookup If the server is registered with the agent, it returns the handle of the server to the client. To begin with, the binding agents location is known to all the nodes.

38

Binding Agent

Client process

Server process

39

Advantages: This method can support multiple servers having the same interface type so that any of the available servers may be used to service the clients request
This helps to achieve a degree of fault tolerance.

Since the bindings are done by the binding agent, when multiple servers provide the same service, the clients can be spread evenly over the servers to balance the load. The binding mechanism can be extended to allow the servers to specify the list of clients who may use its service.
40

Disadvantages:
The overhead involved in binding clients to servers is large & becomes significant when many client processes are short lived. It is necessary that the binding agent should be robust against failures & should not become a performance bottleneck. Distributing the binding function among several binding agents & replicating information among them can satisfy both these criteria. But, replication involves extra overhead of keeping the multiple replicas consistent. Hence, the functionality offered by many binding agents is lower than what is expected.
41

2.6.3 When is it proper to bind a client to a server? Binding Time: A client may be bound to the server at Compile time Link time Call time

42

Binding at Compile time:


Here, the client and server are programmed as if they were intended to be linked together. E.g. the servers network address can be compiled into the client code by the programmer and then it can be found by looking up the servers name in a file.

43

Binding at Link time: In this method, a server process exports its service by registering itself with the binding agent as part of initialization process. A client then makes an import request to the binding agent for the service before making a call. The binding agent binds the client & server by returning to the client the servers handle.

44

Binding at call time: In this method, a client is bound to a server at the time when it calls the server for the first time during its execution. A commonly used approach for binding at call time is indirect call method

45

Binding Agent

Client process

Server process

46

2.6.4 Is it possible for a client to change a binding during execution ? Changing bindings: Basically, Binding is a connection establishment between a client & a server. The client or server of a connection may wish to change the binding at some instance due to some reason
For e.g. A client getting service from a server can change the binding to another server of the same type when a call to already connected server fails. The server of a binding may want to alter the binding & connect the client to another server when the service needs to move to another node.
47

2.6.5 Can a client be simultaneously bound to multiple servers that provide the same service ?
Multiple simultaneous bindings: In a system, a service may be provided by multiple servers. Also, a client is bound to a single server out of a number of servers. But, there may be situations when it is advantageous for a client to be bound simultaneously to all or multiple servers of the same type.

48

Binding of this sort gives rise to multicast communication as all the servers bound to the client for that service will receive and process the call.
E.g. a client may wish to update multiple copies of a file that is replicated at several nodes. For this, the client can be bound simultaneously to all the nodes where the replica of the file is located.

49

2.7 RPC Semantics in case of failure: The goal of RPC is to hide the communication by making remote calls look just like local ones. But, when an error occurs, the differences between the local & remote calls become difficult to mask. Failure handling code is a part of RPC Runtime mechanism.
50

Five different classes of failure :


1. The client is unable to locate the server.

2. The request message from the client to server is lost.


3. The reply message from server to client is lost. 4. The server crashes after receiving a request.

5. The client crashes after sending a request.

51

2.7.1. The client is unable to locate the server Solution . Adding a new error typecannot server

locate

52

2.7.2. The request message from the client to server is lost. To deal with this problem, kernel can be designed to start a TIMER when sending a request. If the timer expires before a reply or acknowledge comes back, the kernel sends the message again Two possibilities:
If the message was actually lost, the server is unable to identify retransmission.
Kernel gives up after a number of tries and concludesthat the server is down.

53

2.7.3 The reply message from server to client is lost.


More difficult scene. Clients kernel may not understand what is the exact problem
Whether request is lost, or reply is lost, or the server is slow.

Some operations can be safely repeated without causing any harm..Idempotent operations
E.g. Reading data from a file

Consider an example of transferring money in banking server.. Non idempotent operationas repeating the operation will harm the data.
54

One way of solving this problem is structure all the requests in an Idempotent way.

not possible for all requests, like banking.


Another way is to have the clients kernel assign each request a sequence no. same request is retransmitted with same sequence no. if there is no problem from the server side , then it can understand the retransmission , & can refuse to carry out the request second time.

55

2.7.4. The server crashes after receiving a request.


Req Receive Execute Reply Rep Normal Case Req Receive Req Receive Execute Crash

No Rep

Crash after exec.

Crash
No Rep Crash before exec.
56

At least once semantics. At most once semantics. Guarantee nothing

57

2.7.5 The client crashes after sending a request. In this scene, the client sends a request to the server & crashes before the server replies. At this point, the computation is active and no parent is waiting for the result.such unwanted computation is called ORPHAN

58

Dealing with orphans: Extermination:


Before a client stub sends a request, it makes a log entry. After the reboot, the log is checked & the orphan is explicitly killed off. This solution is called Extermination

Reincarnation:
This scheme divides the time up into sequentially numbered epochs. When a client reboots, it broadcasts a message to all the machines declaring the start of a new epoch. When such a broadcast comes in, all the remote computations are killed.

59

Gentle reincarnation: When an epoch broadcast comes in, each machine checks to see if it has any remote computations, & if so, tries to locate their owner. Only if the owner can not be fund, is the computation is killed. Expiration: Here, each RPC is given a standard amount of time T, to do the job. If not finished within time, RPC is expired.

60

You might also like