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 toJavabut allows passing objects. RPC follows traditional procedural language constructs while RMI supports object-oriented design.
What is RPC?
RPC代表远程过程调用,这是atype 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 inUnix。
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 theserver称为服务器存根。然后服务器存根在服务器上调用该过程。最后,结果将发送回客户端。
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 asUnix, Linux,Windows和OS X。RPC通常是语言中性的,因此它将数据类型限制在最原始的语言类型上,因为它们必须是所有语言的共同点。RPC中的方法不是面向对象的,而是像C中一样的传统程序机制。
What is RMI?
RMI, which stands for Remote Method Invocation, is anAPI(应用程序编程接口)在Java中实现RPC以支持对象的性质。这允许在另一种情况下调用Java方法Java Virtual machineresiding 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.
RPC和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.
Summary:
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.
图像提供:
- Synchronous versus asynchronous RPCby CAPS entreprise (CC BY-SA 3.0)
发表评论