RPC
Why we need Remote Procedures?
- The client needs an easy way to call the procedures of the server to get some services.
- RPC enables clients to communicate with servers by calling procedures in a similar way to the conventional use of procedure calls in high-level languages.
- RPC is modeled on the local procedure call, but the called procedure is executed in a different process and usually a different computer.
RPC Principles
- Adaption of the
send()&receive()IPC paradigm. - Allows programs in distributed systems to interact with each other via function call/return semantics.
- Abstracts the network to the user and makes it look like the programs are on the same machine.
- Allows to specify a clearly documented interface for the remote server.
- This also allows to automatically generate the code.
- Due to the clearly documented interface, it is easy to write applications that run on multiple operating systems.
RPC Model
- When a process on machine A calls a procedure on machine B, the calling process on A is suspended, and the execution of the called procedure takes place on B.
- Information can be transported from the caller to the callee in the parameters and can come back in the procedure result.
- No message passing or I/O at all is visible to the programmer.
Marshalling
- How does the client transfer its call request (the procedure name) and the arguments to the server via network?
- Marshalling and communication with server:
- For each remote procedure call, a (client) stub procedure is generated and attached to the (client) program.
- Replace the remote procedure call to a (local) call to the stub procedure.
- The (codes in the) stub procedure marshals (the input) arguments and places them into a message together with the procedure identifier (of the remote procedure).
Passing Value Parameters
- Steps involved in doing remote computation through RPC:
!05-web-services, p.16
- Client call to procedure
- Stub builds message
- Message is sent across the network
- Server OS hands message to server stub
- Stub unpacks message
- Stub makes local call to "add"
RPC Issues
- Most RPC systems use call by value as it is easy to realize.
- To implement call by reference a lot has to be done – might not be worth the effort.
- If both systems use the same language parameter, representation is easy!
- If not, there exist special RPC facilities that handle the problem of data representation.
- RPC is more vulnerable to failure (since it involves a communication system, another machine, and another process).
- The programmer should be aware of the call semantics, i.e., programs that make use of RPC must have the capability of handling errors that cannot occur in local procedure calls.