RPC vs RMI
The basic difference between RPC and RMI is that RPC is a mechanism that enables calling of a procedure on a remote computer while RMI is the implementation of RPC in java. RPC is language neutral but only supports primitive data types to be passed. On the other hand, RMI is limited to Java but allows passing objects. RPC follows traditional procedural language constructs while RMI supports object-oriented design.
What is RPC?
RPC, which stands for Remote Procedure Call, is a type of inter-process communication. This allows calling a function in another process running on the local computer or a remote computer. This concept emerged long time ago in 1980, but the first famous implementation was seen in Unix.
RPC involves several steps. The client does a procedure call on the local computer as usual. The module called client stub collect the arguments and create a message and pass to the operating system, Operating system does a system call and sends this message to the remote computer. Operating system in the server collects the message and passes to the module on the server called server stub. Then server stub calls the procedure on the server. Finally, results are sent back to the client.
The advantage of using RPC is that it is independent on the network details. The programmer just has to specify in an abstract fashion while the operating system will look after the internal network details. So this makes programming easier and lets RPC work across any network despite the physical and protocol differences. RPC implementations are present in all mainstream operating systems such as Unix, Linux, Windows and OS X. RPC is generally language neutral hence it limits the data types to the most primitive ones since they must be common to all languages. The approach in RPC is not object oriented, but it is a traditional procedural mechanism like in C.
What is RMI?
RMI, which stands for Remote Method Invocation, is an API (Application Programming Interface) that implements RPC in java to support object orientated nature. This allows calling of Java methods on another Java Virtual machine residing on the same computer or a remote one. The limitation of RMI is that only Java methods can be invoked, but this comes with the advantage that objects can be passed as arguments and return values. When performance is considered RMI is slower than RPC due to the involvement of bytecode on the Java Virtual machine, but RMI is very much programmer friendly, and it is very easy to use.
RMI uses inbuilt security mechanisms in Java and also gives a socket factory that enables usage of non-TCP custom transport layer protocols. Moreover, RMI provides methods to bypass firewalls. The steps that occur in RMI is similar to RPC. The implementation of RMI looks after the internal network details where the programmer does not have to worry about them.
What is the difference between RPC and RMI?
• RPC is language neutral while RMI is limited to Java.
• RPC is procedural like in C, but RMI is object oriented.
• RPC supports only primitive data types while RMI allows objects to be passed as arguments and return values. When using RPC, programmer must split any compound objects to primitive data types.
• RMI is easy to program that RPC.
• RMI is slower than RPC since RMI involves execution of java bytecode.
• RMI allows usage of design patterns due to the object oriented nature while RPC does not have this capability.
RPC vs RMI
RPC is a language neutral mechanism that allows calling of a procedure on a remote computer. However, the language neutral feature limits the data types that are passed as arguments and return values to primitive types. RMI is the implementation of RPC in Java and it supports object passing as well, making the life of the programmer easier. The advantage of RMI is the object oriented design support, but limitation to Java is a disadvantage.