Performance comparison of several Java communication (Rmi,http,hessian,webservice) protocols

Source: Internet
Author: User
Tags xml parser

First, the summary

This paper compares the transmission performance of 5 kinds of communication protocols such as Rmi,hessian,burlap,httpinvoker,web service in different data structures and different data volumes. RMI is the Java language itself provides the communication protocol, stable and efficient, is the basis of EJB. However, it can only be used for communication between Java programs. Hessian and burlap are open-source protocols provided by Caucho, based on HTTP transmission, without opening firewall ports on the service side. The specification of the Protocol is exposed and can be used in any language. Httpinvoker is a remote communication protocol provided by Springframework and 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 heterogeneous languages, communicates in soap form, can be used in any language, and is well supported by many development tools today.

The test results show that the communication efficiency of several protocols is: RMI > Httpinvoker >= Hessian >> Burlap >> Web Servicermi is the preferred remote calling protocol for Java, very efficient and stable, Especially in the case of large data volumes, the gap with other communication protocols is particularly pronounced. Httpinvoker uses the Java serialization technology to transfer objects, which are consistent with RMI in nature. In terms of efficiency, the two are similar, the transmission time of Httpinvoker and RMI is basically flat. Hessian is faster and more efficient than RMI when transmitting a small number of objects, but it is about 20% slower than RMI to transmit objects with complex data structures or large numbers of data objects. Burlap is only a fair speed when transmitting 1 of data, typically 3 times times more than RMI. The inefficiencies of Web service are well known, and on average, Web service traffic is 10 times times more than RMI.

Second, the result analysis

1, direct call directly call all the time is close to 0, which shows that the program processing almost no time spent, the whole time recorded is a remote call spent.

2. RMI invocation As with the assumption, RMI is certainly the quickest, and in almost all cases, it is the least. Especially in the case of complex data structure and large amount of data, the gap with other protocols is especially obvious. In order to give full play to RMI performance, we have also done a test class that does not use spring, uses the original RMI form (inheriting the UnicastRemoteObject object) to serve and remotely invoke, and compares the efficiency of the RMI packaged by spring with the Pojo. The results show that the two are basically flat, and spring offers a slightly faster service. Initially, this is because spring's proxy and caching mechanisms are powerful, saving time for object re-acquisition.

3, Hessian call Caucho Company's resin server claims to be the fastest server, in the Java field has a certain degree of visibility. Hessian as part of the resin, its design is also very streamlined and efficient, as evidenced by the actual operating conditions. On average, Hessian is about 20% slower than RMI, but this is only possible when the data is particularly large and complex, and the Hessian is no slower than RMI when it comes to medium or small amounts of data. The benefit of Hessian is that it is streamlined, can be used across languages, and protocol specifications are exposed, and we can develop the implementation of its protocols for any language. There are currently implemented languages: Java, C + +,. NET, Python, Ruby. There is no Delphi implementation. In addition, Hessian and Web server is very good, with the help of Web server, it can be a great advantage when dealing with a large number of users concurrent access, in terms of resource allocation, thread queuing, exception handling and so on are guaranteed by a mature Web server. RMI itself does not provide multi-threaded servers. Also, RMI needs to open the firewall port, hessian not.

4, burlap call burlap and Hessian are Caucho Company's open source products, but Hessian in binary way, and burlap in XML format. The test results show that the efficiency of burlap is acceptable when the data structure is not complex and the volume is moderate, but if the data volume is large, the efficiency will drop sharply. On average, the burlap call is 3 times times the RMI. I think that there are two reasons for its inefficiency, one is that XML data describes too much, the same data structure, its transmission is much larger, on the other hand, it is well known that the parsing of XML is relatively cost-effective, especially for large data volumes.

5. Httpinvoker call Httpinvoker is a Java remote calling method provided by Springframework, which uses the Java serialization mechanism to handle the transfer of objects. From the test results, its efficiency is still possible, and RMI basically flat. However, it can only be used for communication between the Java languages, and requires both the client and the server to use the spring framework. In addition, Httpinvoker has not been tested in practice and has not yet found a project to apply the protocol.

6, the Web service call this test selected Apache axis components as a Web service implementation, axis in the field of Web service is relatively mature veteran. In order to test only the time of data transmission and encoding, decoding, both the client and the server use caching, and the object simply instantiates once. However, the test results show that the efficiency of Web service is 10 times times slower than other communication protocols. If you take into account the transport of multiple references to the same object, the Web service lags behind more. Because Rmi,hessian and other protocols can pass a reference, and how many references the Web service has, how many copies of the object entity are copied. Too much redundancy in the Web Service transport is one of the reasons for its slowness, and monitoring finds that the same access request, which describes the same data, is 6.5 times times the amount of data returned by the Web service than the Hessian protocol. In addition, the processing of WEB service is very few, the current XML parser efficiency is generally not high, processing XML <-> beans is very resource. From the test results, the remote call is faster than the local call, but also from the side of the main use to encode and decode the XML file. This is more serious than redundant information, which consumes only the network bandwidth, and the resource consumption of each invocation directly affects the load capacity of the server. (MS engineers have said that using a Web service cannot load more than 100 concurrent users.) The testing process also found that the Web service coding is not very convenient, for non-basic types need to register the serialization and deserialization class, it is cumbersome to generate stubs more tired than spring + Rmi/hessian processing so smooth and concise. Also, Web service does not support collection types, only arrays, inconvenient.

Performance comparison of several Java communication (Rmi,http,hessian,webservice) protocols

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.