Professional Documents
Culture Documents
Remote Procedure Call (RPC) Fundamentals: Jasintha Dasanayake
Remote Procedure Call (RPC) Fundamentals: Jasintha Dasanayake
Jasintha Dasanayake
2011 - Level - 3 1st Semester (September - February) Uva Wellassa University of Sri Lanka
What is RPC?
RPC is an inter-process communication It is a protocol that allows invoking a process on another machine An RPC is initiated by the client, which sends a request message to a known remote server to execute a specified procedure with supplied parameters
Wrap the parameters of the call in a message. Send the message to the remove machine . Pass the parameters via local procedure call. Return the result in a message .
Y = p(X)
Main(x)
P-->Y
local PC
local PC
Stub client
x Y
x Y
Y stub Sever
Caller
Caller
Callee
Callee
Stub
Network
stub
Local procedure call can be transformed into a remote procedure call The caller is the client, the callee is the server
Remote procedure calls are normally synchronous like local procedure calls The difference is how long you may have to wait
Stubs in RPC
The stubs in RPC are responsible for packing and unpacking the call parameters, and the call results
At-least-once
Operations that have the same effect when invoked more than once
At-most-once
Which require a guarantee that multiple invocations of the same RPC call by a client will not be processed on the server Usually maintain state information on the server More than one invocation of the same RPC call must be detected in order to avoid corruption of the state information. At-most-once semantics exact higher overhead in terms of processing and network use and should only be used when necessary.
At-most-once
Examples :
Exactly-once
One time Invocation Much harder to achieve under failure conditions Straightforward implementation under normal conditions... At-least-once + At-most-once = Exactly-once
RPC semantics-Summery
RCP Call Retry request Message Duplicate filtering in server side NO Response
At-least-once
YES
At-Most-once
YES
YES
Re-transmit
Passing parameters is typically the only way that RPC-based clients and servers share information Parameter-passing has possible modes
IN: pass info from caller to callee OUT: callee writes a value in the caller IN/OUT: caller tells callee value of var, which may be updated by callee
Call by value:
IN Mode Value passed to procedure is copied to local variable Cant have an effect on caller variable
Call by reference:
Call by copy/restore:
IN/OUT mode Call by value + call by reference Call by value at entry of procedure and restricts the call by reference to the exit of the call Results are copied back to the calling procedure at the completion of the called procedure
RPC -BINDING
When server machine is unknown, the client will need to locate the server machine by contacting directory server to locate address of server system
When server machine is unknown, the client will need to locate the server machine by contacting directory server to locate address of server system
Server starts registers its communication endpoint by sending request to port mapper that contains servers program, version number and port number
Client process contact port mapper to obtain handler for accessing server with specific program and version number. This is done by RPC run-time library routine create.
The port mapper returns the port number of the server to the client system after verifying the program and version number.
Client system builds client handle for the client process for subsequent use in the remote procedure call. Binding process establish socket connection between client and server
RPC-COMPILATION
RPC-COMPILATION
An interface specification file RPC generator which takes the interface specification file as input and produces the client and server stub procedure source code as output A run-time library for the supporting execution of RPC
client Stubs
Interface Definition
IDL
Compi ler
Header Files
Server Stubs
Compi ler
Server Stubs
Header Files
Compil er
Server Application
client codes
Compil er
client Application
Compi ler
Server Stubs
Header Files
Compil er
Server Application
client codes
Compil er
client Application
Compi ler
Server Stubs
Header Files
Compil er
Server Application
messages
Request Message Sent
Lost
Delayed
Solutions ?????
Server Crash
Exactly once
Before request arrives Before reply After reply, but reply dropped
At most once
At least once
Server Crash
SOLUTIONS:
Use at least once semantics and to log the cache table When the server recovers it reloads cache table from log
Client Crash
The server occasionally tries to locate the its clients Reboot of failed client Operation is given a maximum lifetime
A
Client A--->B Time out
Client
C
Server
>
Invocation (synchronous)
Invocation (synchronous)
Client
Main(x)
server
P(x) stub(x)
X
X Y Q(x)
blocked
w(y)
Y
S(q,x) s(q)
R(q)
Return
Invocation (synchronous)
Client invoke the remote method and waiting for result These type of operations block the client side invocation
Examples
server
initiating stub(x)
P(x)
X
Q(x)
w()
S w() redeeming
R(q)
Return
Initiating an operation is asynchronous The initiator is given a voucher When the initiator is ready for the result of the operation, it redeems it Initiate/Redeem is also known as follow-up RPC (FRPC)
Examples