Comparison of several remote service calling protocols in java

1. Overview
This paper compares the transmission performance of five communication protocols such as RMI, Hessian, Burlap, Httpinvoker, and web service with different data structures and different data volumes.
RMI is a remote communication protocol provided by the java language itself, which is stable and efficient, and is the basis of EJB. But it can only be used for communication between JAVA programs.
Hessian and Burlap are open source protocols provided by caucho. They are based on HTTP transmission, and the server does not need to open firewall ports. The specification of the protocol is public and can be used in any language.
Httpinvoker is a remote communication protocol provided by SpringFramework, which can only be used for communication between JAVA programs, and the server and client must use SpringFramework.
Web service is the preferred protocol for connecting heterogeneous systems or languages. It uses SOAP for communication and can be used in any language. Many current development tools support it very well.
 



The test results show that the communication efficiency of several protocols is as follows:
RMI > Httpinvoker >= Hessian >> Burlap >> web service
RMI is worthy of being the preferred remote invocation protocol of JAVA, which is very efficient and stable, especially in the case of large data volume, the gap with other communication protocols is particularly obvious.
HttpInvoker uses java's serialization technology to transfer objects, which is essentially consistent with RMI. In terms of efficiency, the two are almost the same. The transmission time of HttpInvoker and RMI is basically the same.
Hessian is faster and more efficient than RMI when transferring a small number of objects, but it is about 20% slower than RMI when transferring objects with complex data structures or a large number of data objects.
Burlap is only moderately fast when transmitting 1 data, and under normal circumstances, its millisecond is 3 times that of RMI.
The inefficiency of Web Services is well known. On average, the communication of Web Services is 10 times faster than that of RMI.

 

 

2. Analysis of the results
1. Direct call
All the milliseconds of direct calls are close to 0, which means that almost no time is spent in program processing, and all the time recorded is spent on remote calls.
2. RMI call
As envisaged, RMI is of course the fastest, and in almost all cases it is the least millisecond. Especially in the case of complex data structure and large amount of data, the gap with other protocols is particularly obvious.
In order to give full play to the performance of RMI, another test class is made, instead of using Spring, the original RMI form (inheriting the UnicastRemoteObject object) is used to provide services and call them remotely, and compare the efficiency with the RMI packaged into POJO by Spring. The results show that the two are basically the same, and the services provided by Spring are slightly faster.
It is initially believed that this is because Spring's proxy and caching mechanisms are relatively powerful, which saves the time for object re-acquisition.
3. Hessian call
Caucho's resin server claims to be the fastest server and has a certain reputation in the java field. As a component of resin, Hessian is also very compact and efficient in design, and the actual operation also proves this. On average, Hessian is about 20% slower than RMI, but this is only manifested when the amount of data is very large and the data structure is very complex. For medium or small amounts of data, Hessian is not slower than RMI.
The advantages of Hessian are that it is streamlined and efficient, can be used across languages, and the protocol specification is open, and we can develop an implementation of its protocol for any language. Currently implemented languages ​​are: java, c++, .net, python, ruby. There is no implementation in delphi yet.
In addition, Hessian is very well integrated with the WEB server. With the mature functions of the WEB server, it will have great advantages in handling concurrent access of a large number of users. In terms of resource allocation, thread queuing, exception handling, etc., mature WEB servers can be guaranteed. And RMI itself does not provide a multi-threaded server. Moreover, RMI needs to open firewall ports, Hessian does not.
4. Burlap call
Both Burlap and Hessian are open source products of caucho company, but Hessian adopts binary format, while Burlap adopts xml format.
The test results show that Burlap's efficiency is acceptable when the data structure is not complex and the data volume is moderate, but if the data volume is large, the efficiency will drop sharply. On average, Burlap's invocation time is 3 times that of RMI.
我认为,其效率低有两方面的原因,一个是XML数据描述内容太多,同样的数据结构,其传输量要大很多;另一方面,众所周知,对xml的解析是比较费资源的,特别对于大数据量情况下更是如此。
5、HttpInvoker调用
HttpInvoker是SpringFramework提供的JAVA远程调用方法,使用java的序列化机制处理对象的传输。从测试结果看,其效率还是可以的,与RMI基本持平。
不过,它只能用于JAVA语言之间的通讯,而且,要求客户端和服务端都使用SPRING框架。
另外,HttpInvoker 并没有经过实践的检验,目前还没有找到应用该协议的项目。
6、web service调用
       本次测试选用了apache的AXIS组件作为WEB SERVICE的实现,AXIS在WEB SERVICE领域相对成熟老牌。
为了仅测试数据传输和编码、解码的时间,客户端和服务端都使用了缓存,对象只需实例化一次。但是,测试结果显示,web service的效率还是要比其他通讯协议慢10倍。
如果考虑到多个引用指向同一对象的传输情况,web service要落后更多。因为RMI,Hessian等协议都可以传递引用,而web service有多少个引用,就要复制多少份对象实体。
Web service传输的冗余信息过多是其速度慢的原因之一,监控发现,同样的访问请求,描述相同的数据,web service返回的数据量是hessian协议的6.5倍。另外,WEB SERVICE的处理也很毫时,目前的xml解析器效率普遍不高,处理xml <-> bean很毫资源。从测试结果看,异地调用比本地调用要快,也从侧面说明了其毫时主要用在编码和解码xml文件上。这比冗余信息更为严重,冗余信息占用的只是网络带宽,而每次调用的资源耗费直接影响到服务器的负载能力。(MS的工程师曾说过,用WEB SERVICE不能负载100个以上的并发用户。)
测试过程中还发现,web service编码不甚方便,对非基本类型需要逐个注册序列化和反序列化类,很麻烦,生成stub更累,不如spring + RMI/hessian处理那么流畅简洁。而且,web service不支持集合类型,只能用数组,不方便。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326943423&siteId=291194637