RPC - For Class
RPC - For Class
By
BENAY KUMAR RAY
Asst. Professor,
Central University of South Bihar
Problems with Sockets
Sockets are a fundamental part of client-server
networking.
They provide a relatively easy mechanism for a
program to establish a connection to another
program.
Either on a remote or local machine and send
messages back and forth
Moreover, they are the only interface to the
network that most operating systems provide.
Problems with Sockets
It connects, then read/write & finally disconnect. That’s not the usual
way we program. We use Procedure Call.
In design single-process applications, the procedure call is usually
the standard, most popular, and most familiar interface model
If we want to make distributed computing look like centralized
computing, input-output-based streams are not the way to accomplish
this.
Too straightforward to achieve Distributed System properties.
The procedures send and receive do not conceal communication at
all.
Which is important to achieve access transparency in distributed
system
Solution : Remote Procedure Call
Proposed By Birrell and Nelson (1984)
Mechanisms to call procedures on other machines
Processes on machine A can call procedures on machine B
1. Calling process on machine A is suspended
2. Execution of called procedures takes place on B
3. When B returns the result, control passed back to A
4. A is resumed
It should appear to the programmer that a normal
procedure call is taking place
No message passing or I/O is visible to the programmer
Used by both Operating Systems and Applications:
NFS is implemented as a set of RPCs
CORBA, Java RMI are just RPC Systems.
Conventional Procedure Call Mechanism
System Call
Operating System
Remote Procedure Call: Client and Server
Stubs
The idea behind RPC is to make a remote procedure call look
as much as possible like a local one.
We want RPC to be transparent-the calling procedure should
not be aware that the called procedure is executing on a
different machine or vice versa
Note: (in case of single processor system) When program needs
to read some data from a file.
The programmer puts a call to read in the code to get the data
In a single-processor system, the read routine is extracted
from the library by the linker and inserted into the object
program.
It is a short procedure, which is generally implemented by
calling an equivalent read system call.
read procedure is a kind of interface between the user code
and the local operating system..
Remote Procedure Call: Client and Server
Stubs
In case of RPC: Client Stub
When read is actually a remote procedure, a different version
of read, called a client stub, is put into the library.
Like the traditional or conventional one, it too, is called using
the same calling sequence.
Like the conventional one, it too, does a call to the local
operating system.
But only unlike the original one, it does not ask the operating
system to give it data.
Instead, it packs the parameters into a message and requests
that message to be sent to the server
Explicit typing
Types are transmitted with values
E.g., XML
Dynamic Binding
Clients need binding with Server before communication. How
Client finds Server?
Static binding uses Server’s address as hardcoded in the Client
code.
Disadvantage: If server moves or replicated, the numerous
programs will have to be found and recompiled.
Dynamic binding uses a program, called binder, to bind with
Server at Runtime.
Call By Input Output
register Server Name, Version, Handle, UniqueId
MyName
Naming Service OtherName
---
Client Server
Create
Remote Object
X
Failure C ? S
X
RPC Failures:
Client unable to locate Server
Request message from Client to Server is lost
Reply message from Server to Client is lost
Server crashes after receiving a request
Client crashes after sending a request
Locked resources.
orphan
Solution:
Extermination :
• Client stub maintains a log & kills the orphans explicitly at
reboot.
• Disadvantage:
Log maintenance is expensive.
Orphans may create grand-orphans by doing RPCs.
Its very difficult to locate them
Even after locating they may not be killed due to
partitioned network.
Failure (Cont.)
Reincarnation :
• Divide times in epochs
• Client broadcasts new epoch when reboots
• Upon hearing a new epoch servers kills the remote
computation on behalf on that client
Gentle Reincarnation :
• When an epoch broadcast comes in, each machine check
to see if it has any remote computations
• If found, tries to locate their owner
• Only if the owner cannot be found is the computation killed.
Expiration :
• Each RPC is given a lease T to finish computation
• If it does not, it needs to ask for another lease
• If client reboots after T sec all orphans are gone
Problem: what is a good value of T?
Examples: CORBA
If existing system is integrated to form Distributed
System then the problems arises are:
Different Operating System
Different Languages
Solution: CORBA