Lect4 - Remote Procedure Calls
Lect4 - Remote Procedure Calls
1
Introduction
IPC part of distributed system can often be
conveniently handled by message-passing model.
It doesn't offer a uniform panacea for all the needs.
It can be said as the special case of message-passing
model.
2
RPC
It has become widely accepted because of the
following features:
Simple call syntax and similarity to local procedure calls.
It specifies a well defined interface and this property
supports compile-time type checking and automated
interface generation.
Its ease of use, efficiency and generality.
It can be used as an IPC mechanism between processes on
different machines and also between different processes on
the same machine.
3
RPC Model
It is similar to commonly used function / procedure
call model. It works in the following manner:
1. For making a procedure call, the caller places arguments
to the procedure in some well specified location.
2. Control is then transferred to the sequence of instructions
that constitutes the body of the procedure.
3. The procedure body is executed in a newly created
execution environment that includes copies of the
arguments given in the calling instruction.
4
Cont…
4. After the procedure execution is over, control returns to
the calling point, returning a result.
Since the caller and the callee processes have disjoint address
space, the remote procedure has no access to data and
variables of the callers environment.
5
Cont…
Therefore RPC facility uses a message-passing scheme for
information exchange between the caller and the callee
processes.
6
Cont…
7
Cont…
It is not always necessary that the caller gets blocked.
There can be RPC implementations depending on the
parallelism of the caller and the callee’s environment or other
features.
The RPC could be asynchronous, so that the client may do
useful work while waiting for the reply from the server.
Server can create a thread to process an incoming request so
that the server can be free to receive other requests.
8
Transparency of RPC
A transparent RPC is one in which the local and remote
procedure calls are indistinguishable to the programmers.
Types of transparencies:
Syntactic transparency
A remote procedure call should have exactly the same syntax as a
local procedure call.
Semantic transparency
The semantics of a remote procedure call are identical to those of a
local procedure call.
10
Cont…
11
Implementing RPC Mechanism
12
Cont…
Stubs
Provide a normal / local procedure call abstraction by
concealing the underlying RPC mechanism.
A separate stub procedure is associated with both the client
and server processes.
To hide the underlying communication network, RPC
communication package known as RPC Runtime is used
on both the sides.
13
Cont…
Thus implementation of RPC involves the five
elements of program:
1. Client
2. Client Stub
3. RPC Runtime
4. Server stub
5. Server
14
Cont…
The client, the client stub, and one instance of
RPCRuntime execute on the client machine.
The server, the server stub, and one instance of
RPCRuntime execute on the server machine.
As far as the client is concerned, remote services are
accessed by the user by making ordinary local procedure
calls instead of using the send and receive primitives.
15
16
Client Stub
It is responsible for the following two tasks:
On receipt of a call request from the client:
it packs the specifications of the target procedure and
the arguments into a message &
asks the local RPC Runtime to send it to the server
stub.
17
RPCRuntime
It handles transmission of messages across the
network between Client and the server machine.
It is responsible for
Retransmission,
Acknowledgement,
Routing &
Encryption.
18
Server Stub
It is responsible for the following two tasks:
19
Stub Generation
Stubs can be generated in one of the following two
ways:
Manually &
Automatically
20
Automatic Stub Generation
Interface Definition Language (IDL)
Used to define interface between a client and the
server.
Interface definition:
It is a list of procedure names supported by the
interface together with the types of their
arguments and results.
22
Cont…
IDL compiler generates:
components that can be combined with client and
server programs, without making any changes to
the existing compilers;
client stub and server stub procedures;
appropriate marshaling and unmarshaling
operations;
a header file that supports the data types.
23
RPC Messages
RPC system is independent of transport protocols and is not
concerned as to how a message is passed from one process
to another.
24
Call Messages
Components necessary in a call message are:
1. The identification Information of the remote procedure
to be executed.
25
Call Messages
4. Message Type field is used to distinguish between call
and reply messages.
26
Call Message Format
27
Reply Messages
These are sent by the server to the client for
returning the result of remote procedure
execution.
28
Cont…
Conditions for unsuccessful message sent by
the server:
The server finds that the call message is not
intelligible to it.
Client is not authorized to use the service.
Remote procedure identifier is missing.
The remote procedure is not able to decode the
supplied arguments.
Occurrence of exception condition.
29
Reply message formats
31
Marshalling Arguments and Results
Encoding and decoding of messages in RPC is
known as marshaling & Unmarshaling,
respectively.
32
Server Management
Issues :
Server implementation
Server creation
33
Server Implementation
Types of servers :
Stateful servers
Stateless servers
34
Stateful Server
A Stateful Server maintains clients state
information from one RPC to the next.
35
Stateful file server
Return(bytes 0 to 99)
36
Stateless Server
Every request from a client must be
accompanied with all necessary parameters to
successfully carry out the desired operation.
37
Stateless file server
38
Server Creation Semantics
A server process is independent of a client
process that makes a remote procedure call to
it.
39
Server Creation Semantics
Servers based on the life duration for which RPC
servers survive:
Instance-per-call Servers
Instance-per-session Server
Persistent Servers
40
Instance-per-call Servers
These exist only for the duration of a single call.
42
Persistent Servers
Persistent servers remain in existence
indefinitely.
Advantages:
Most commonly used.
Improves performance and reliability.
Shared by many clients.
43
Parameter Passing Semantics
Call by Value Semantics
44
Call-by-value
All parameters are copied into a message that is
transmitted from the client to the server through
the intervening network.
45
Call-by-reference
RPC mechanisms can use the call-by-reference
semantics for parameter passing
The client and the server exist in different address
space.
46
Call-by- object -reference
A call-by-reference in which objects invocation is
used by the RPC mechanism.
47
Call-by-move
Call-by-move
A parameter is passed by reference as in the method of
call-by-object-reference, but at the time of the call, the
parameter object is moved to the destination node
(callee) or
May remains at the caller’s node.
Thus call-by-visit or move.
48
Call Semantics
Failure of communication link between the caller
and the callee node is possible.
49
Types of Call Semantics
Possibly or May-Be Call Semantics
Last-one call semantics
Last-of-many call semantics
At-least-once call semantics
Exactly-once call semantics
50
Possibly or May-Be Call Semantics
It is a Request Protocol.
It uses time out but no surety of reply.
It is an Asynchronous RPC.
Server need not send back the reply.
Useful for periodic update services.
51
Last-One Call Semantic
It is Request / Reply protocol.
53
At-least-once Call Semantic
It guarantees that the call is executed one or more times but
does not specify which results are returned to the caller.
If there are any orphan calls, it takes the result of the first
response message and ignores the others, whether or not the
accepted response is from an orphan.
54
Exactly-Once Call Semantics
It is Request / Reply / ACK protocol.
56
Request (R) protocol
Client Server
57
Request / Reply (RR) protocol
Client Server
Request message
First Procedure
RPC execution
Reply message
Also serves as acknowledge-
Ment for the request message
Request message
Next Procedure
RPC execution
Reply message
Also serves as acknowledge-
Ment for the request message
58
Request /Reply /Acknowledge-Reply
(RRA) protocol
Client Server
Request message
First Procedure
RPC execution
Reply message
Reply acknowledgement msg
Request message
Next Procedure
RPC execution
Reply message
59
Complicated RPC’s
Types of complicated RPCs
60
RPCs involving Long-Duration Calls
& Large Gaps Between Calls
61
Periodic probing of the server by the clients
62
Periodic generation of an ACK by the server
63
RPC’s involving Long Messages
It proposes the use of multidatagram messages.
64
Client – Server Binding
Client Stub must know the location of a server before RPC
can take place between them.
Process by which client gets associated with server is known
as BINDING.
Servers export their operations to register their willingness to
provide services &
Clients import operations, asking the RPCRuntime to locate
a server and establish any state that may be needed at each
end.
65
Cont…
Issues for 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?
66
Server Naming
The naming issue is the specification by a client of a server
with which it wants to communicate.
67
Cont…
Interface name semantics are based on an arrangement
between the exporter and importer.
Interface names are created by the users, not by the RPC
package.
The RPC package only dictates the means by which an
importer uses the interface name to locate an exporter.
68
Server locating
Methods are:
1. Broadcasting
2. Binding agent
69
Broadcasting
A message to locate a node is broadcast to all
the nodes from the client node.
70
Binding Agent
It is basically a name server used to bind a client to a server by
providing the client with the location information of the
desired server.
71
Cont…
The location of the binding agent (having a fixed address) is
known to all nodes by using a broadcast message .
72
Cont…
1. The server registers itself
with the binding agent.
Binding
2. The client requests the Agent
binding agent for the server’s
location. 2
1
3. The binding agent returns the 3
server’s location information
to the client.
Client 4 Server
4. The client calls the server. Process Process
73
Cont…
Advantages
74
Cont…
Disadvantages
The overhead involved in binding clients to servers is
large and becomes significant when many client
processes are short lived.
75
Cont…
Solution
distribute the binding function among several binding
agents, and
76
Binding Time
Binding at compile time
77
Binding at compile time
78
Binding at link time
Client makes an import request to the binding agent for
the service before making a call.
79
Binding at call time (Indirect Call)
80
Binding at call time by the method of indirect call
83
Security issues
Is the authentication of the server by the client required?
84
Some special types or RPCs
Callback RPC
Broadcast RPC
Batch-made RPC
85
Callback RPC
It facilitates a peer-to-Peer paradigm among
participating processes.
Issues
Providing server with clients handle
Making the client process wait for the callback RPC
Handling callback deadlocks
86
Cont…
Client Server
87
Broadcast RPC
A client’s request is broadcast on the network
and is processed by all the servers that have
the concerned procedure for processing that
request.
88
Cont…
Methods for broadcasting a client’s request:
89
Cont…
Back-off algorithm can be used to increase the time
between retransmissions.
90
Batch-mode RPC
Batch-mode RPC is used to queue separate RPC requests
in a transmission buffer on the client side and then send
them over the network in one batch to the server.
91
Lightweight RPC (LRPC)
The communication traffic in operating systems are of two
types:
1. Cross-domain - involves communication between
domains on the same machine.
92
Cont…
For cross domain, user level server processes have its own
address space.
93
Cont…
Techniques used by LRPC for better performance:
Simple stubs
94
Simple control transfer
It uses a special threads scheduling mechanism,
called handoff scheduling for direct context
switch from the client thread to the server thread
of an LRPC.
95
Simple data transfer
LRPC reduces the cost of data transfer by
performing fewer copies of the data during its
transfer from one domain to another.
96
Cont…
Pairwise allocation of argument stacks enables
LRPC to provide a private channel between the
client and server and also
Allows the copying of parameters and results as
many times as are necessary to ensure correct
and safe operation.
97
Simple stub
Every procedure has a call stub in the client’s
domain and an entry stub in the server’s
domain.
At the time of transfer of control, kernel
associates execution stack with the initial call
frame expected by the server procedure.
Now it directly invokes the corresponding
procedure’s entry in servers domain.
Thus LRPC stubs blur the boundaries between
the protocol layers.
98
Optimizations for better performance
Concurrent access to multiple servers
Serving multiple requests simultaneously
Reducing per-call workload of servers
Reply caching of idempotent remote procedures
Proper selection of timeout values
Proper design of RPC protocol specification
Only 3 out of 13 header fields of IP Suite (both TCP/IP &
UDP/IP) are used.
99
Reading
Pg 212 – Pg 222
100