Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 50

Remote Procedure Call (RPC) fundamentals

Jasintha Dasanayake
2011 - Level - 3 1st Semester (September - February) Uva Wellassa University of Sri Lanka

What is RPC?

RPC is called remote invocation or remote method invocation. Note :

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

Basic Steps of RPC

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

Remote Procedure Call (RPC)

Caller

Caller

Callee

Callee

Stub

Network

stub

Local procedure call

Remote Procedure Call(RPC)

Local procedure call can be transformed into a remote procedure call The caller is the client, the callee is the server

Caller Waits for Callee

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

packing - Marshalling. Unpacking -Unmarshalling

RPC execution semantics

At-least-once At-most-once: the realistic case

Exactly-once: the ideal case

At-least-once

Operations that have the same effect when invoked more than once

these are called idempotent

It has a straightforward implementation Example :

add 50 units to stock level ? ?

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 :

Money Withdrawing request in ATM systems ? ? ?

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

Re-Execute the procedure

At-Most-once

YES

YES

Re-transmit

RPC - Parameter Passing

RPC - Parameter Passing

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

RPC - Parameter Passing

Parameter passing methods :

Call by value Call by reference Call by copy/restore

RPC - Parameter Passing

Call by value:

IN Mode Value passed to procedure is copied to local variable Cant have an effect on caller variable

Call by reference:

IN/OUT mode Pass pointer address Same memory location is referred

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

There are two basic ways of using an operation

Invocation (synchronous) Initiate and redeem (asynchronous)

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

Three major components in the RPC package

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

IDL-interface description language (or alternatively, interface definition language)

client Stubs Interface Definition IDL

Compi ler
Server Stubs

Header Files

Compil er

Server Application

Developed the Server side


Server code

client codes

client Stubs Interface Definition IDL

Compil er

client Application

Compi ler
Server Stubs

Header Files

Compil er

Server Application

Developed the Client side


Server code

client codes

client Stubs Interface Definition IDL

Compil er

client Application

Compi ler
Server Stubs

Header Files

Compil er

Server Application

Complete RPC Application


Server code

RPC FAILURE HANDLING

RPC FAILURE HANDLING

Can be Three types of failures

Lost/delay the messages Server side Crash Client side Crash

RPC FAILURE HANDLING

- Lost or Delay the

messages
Request Message Sent

Message may delay or lost

Eventually detected by time out or no response form server

Lost

Delayed

server will receive two request

Solutions ?????

RPC FAILURE HANDLING

Server Crash

Exactly once

Before request arrives Before reply After reply, but reply dropped

At most once

Cant know if request was done

At least once

Keep retrying across crashes

RPC FAILURE HANDLING

Server Crash

SOLUTIONS:

Use at least once semantics and to log the cache table When the server recovers it reloads cache table from log

RPC FAILURE HANDLING

Client Crash

Before server completes the client request

Server reply is undeliverable


No easy way for the server to detect the disappearance of clients Solutions :

The server occasionally tries to locate the its clients Reboot of failed client Operation is given a maximum lifetime

The nested timeout problem


B

A
Client A--->B Time out

Client

C
Server

>

B--->C Time out

Ways of using an RPC Operation

Ways of using an RPC Operation

Two ways of operation invocation in RCP

Invocation (synchronous)

Initiate and redeem (asynchronous)

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

client side totally depends on the server side executions/results

Examples

Credit Card verification in a checkout process ? ? ?

Initiate and Redeem (asynchronous)


Client
Main(x)

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

Show the delivery date of online perches items ? ? ?

You might also like