Remote Procedure Call (RPC)
Remote Procedure Call (RPC)
An extension of conventional procedure call (used for transfer of control and data within a single process)
allows a client application to call procedures in a different address space in the same or remote machine
ideal for the client-server modeled applications primary goal is to make distributed programming easy, which is achieved by making the semantics of RPC as close as possible to conventional local procedure call what is the semantics of local procedure call?
RPC Communication
RPC System Components Message module IPC module of Send/Receive/Reply responsible for exchanging messages Stub procedures (client and server stubs) a stub is a communications interface that implements the RPC protocol and specifies how messages are constructed and exchanged responsible for packing and unpacking of arguments and results (this is also referred to as marshaling) these procedures are automatically generated by stub generators or protocol compilers (more later)
Client stub packs the arguments with the procedure name or ID into a message sends the msg to the server and then awaits a reply msg unpacks the results and returns them to the client
Server stub receives a request msg unpacks the arguments and calls the appropriate server procedure when it returns, packs the result and sends a reply msg back to the client
RPC Design Issues Parameter Passing in conventional calls: pass by-value and pass byreference possible in RPC: pass by-value only (why?) pointers (addresses) are meaningless in a separate address space Also called copy-in/copy-out parameter passing Single vs. multiple input and output parameters
most RPC implementations allow the user to choose the underlying transport service
why is the connectionless transport service more desirable for supporting RPCs? 1. RPC messages are generally short and overhead involved with connections may be undesirable 2. Servers generally serve a large number of clients and maintaining state information on connections may be undesirable 3. LANs are generally reliable
RPC Semantics
during a RPC, problems may occur: 1. Request msg may be lost
Some strategies for different RPC msg delivery guarantees 1. Retry request message - retransmit the request msg until either a reply is received or the server is assumed to have failed 2. Duplicate filtering - filtering duplicate requests at the server when retransmissions are used 3. Retransmission of replies - keep a history of reply messages to enable lost replies to be retransmitted without re-executing the server operations
RPC mechanisms usually include timeouts to prevent clients waiting indefinitely for reply msgs
RPC call semantics maybe call semantics at-least-once call semantics at-most-once call semantics
1. maybe call semantics no retransmission of request messages not certain whether the procedure has been executed no fault-tolerance measures generally not acceptable
more complex support required due to the need for request msg filtering and for keeping track of replies
Binding
binding refers to determining the location and identity (communication ID) of the called procedure in UNIX: a communication ID is a socket address containing hosts Internet address and a port number
static binding (which binds the host address of a server into the client program at compilation time) is undesirable (why?) The client and server programs are compiled separately and often at different times The server may be moved from one host to another dynamic binding is more desirable
allows servers to register their exporting services allows servers to remove services allows clients to lookup the named service
3. Use a broadcast message to locate the binder the binder can be easily relocated client & server programs need not be recompiled most flexible approach
Asynchronous RPC RPC calls that do not block waiting for replies more efficient than synchronous RPC when replies are not required When no reply message is required - a client can make a RPC and proceed without waiting for the server to complete the operation - several client requests can be buffered and transmitted together When a reply message is required - a client can make a call, proceed with other operations and claim the reply later e.g., X-Window system - X Window manager as a server - X Window applications as clients
Asynchronous RPCs
Essence: Try to get rid of the strict request-reply behavior, but let the client continue without waiting for an answer from the server.