Skip to main content

Compare RPC and RMI

Short answer

RMI is the object-oriented extension of RPC, enabling method invocation on remote objects. Unlike RPC's procedural calls, RMI supports objects, inheritance, polymorphism, passing objects by reference, and distributed garbage collection, making it superior for complex distributed applications.

What do you mean by RMI software? Comparatively discuss RPC with RMI. (Explain RMI with suitable diagram. How is RMI superior to RPC?)

RMI software

Remote Method Invocation (RMI) is the object-oriented extension of RPC. An object in one process invokes a method of an object in another process (possibly on another host) through a remote object reference. In Java, RMI is built into the language; CORBA does the same for many languages.

Architecture

 Client                         Server
 +-------------+                +-------------+
 | Client obj  |                | Remote obj  |
 | Proxy (stub)|                | Skeleton    |
 | Remote ref  |<-- network --->| Dispatcher  |
 | module      |                | Remote ref  |
 | Comm module |                | Comm module |
 +-------------+                +-------------+
        ^        Remote reference module: translates local <-> remote refs
        +--- Object registry / naming service: look up by name
  • Proxy (stub): local representative of the remote object; marshals arguments and sends the request.
  • Skeleton / dispatcher: the dispatcher selects the method, and the skeleton unmarshals the request, calls the object and marshals the reply.
  • Remote reference module: converts between local and remote object references.
  • Communication module: carries request-reply messages with a chosen invocation semantics.
  • Registry / binder: the client finds the remote object by name.

Java RMI example: the server defines an interface extending java.rmi.Remote, implements it and registers it in the RMI registry (Naming.rebind); the client calls Naming.lookup to get a stub and calls methods on it. The stub (and, in old versions, the skeleton) is generated by rmic, or dynamically by the runtime in modern Java.

RPC versus RMI

PointRPCRMI
ParadigmProcedure orientedObject oriented
What is calledA remote procedure/functionA method of a remote object
ParametersOrdinary data, passed by value (structures)Objects too, passed by value (serialised) or by remote reference
Object identityNoneRemote object references identify objects
StateProcedures usually without object stateMethods work on the state of an object
LanguageUsually language independent (C, XDR)Java RMI is Java only; CORBA is language independent
InterfaceIDL such as Sun XDR/rpcgenJava interface or CORBA IDL
Garbage collectionNot applicableDistributed garbage collection of remote objects
Polymorphism, inheritanceNot supportedSupported
UseProcedural client-serverComplex distributed object applications

How RMI is superior

RMI supports objects, inheritance, polymorphism and passing objects as parameters, has a distributed garbage collector, gives better security (security manager, class loading) and allows a truly object-oriented design of distributed applications, which RPC cannot.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Distributed System chapter 2 questions →