Comparison of common communication protocols in Java--Reprint:
Compare RMI,Hessian,Burlap,httpinvoker,Web service The transmission performance of 5 kinds of communication protocols in different data structures and different data volumes.
1. Introduction
RMIIs the Java language itself provides a remote communication protocol, stable and efficient, is the basis of EJB. However, it can only be used for communication between Java programs.
HessianAnd
Burlapis the open source protocol provided by Caucho, based on HTTP transmission, the service side does not open firewall port. The specification of the Protocol is exposed and can be used in any language.
Httpinvokeris the 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 Serviceis the preferred protocol for connecting heterogeneous or heterogeneous languages, it communicates in soap form, can be used in any language, and many of the development tools currently support it well.
2. Test resultsThe test results show that the communication efficiency of several protocols is:
RMI > Httpinvoker >= Hessian >> Burlap >> Web service
RMIJava is the preferred remote call protocol, very efficient and stable, especially in the case of large data volume, and other communication protocols, especially the gap.
HttpinvokerUsing the Java serialization technology to transfer objects is consistent with RMI in nature.
In terms of efficiency, the two are similar, the transmission time of Httpinvoker and RMI is basically flat.
HessianWhen transferring a small number of objects, it is faster and more efficient than RMI, but it is about 20% slower than RMI to transport objects with complex data structures or large numbers of data objects.
BurlapIt is only a fair speed when transmitting 1 of data, and it typically takes 3 times times more time than RMI.
Web ServiceInefficiency is well known, on average, Web service communication is 10 times times the RMI.
3. Results Analysis
1. Call DirectlyAll of the direct calls are close to 0, which means that the program processing takes almost no time, and the entire time recorded is spent on remote calls.
2. RMI InvocationAs envisaged, RMI is certainly the quickest, and in almost all cases, it takes the least time. Especially in the case of complex data structure and large amount of data, the gap with other protocols is especially obvious.
3. Hessian callCaucho Company's resin server is known as the fastest server, in the Java domain 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. In addition, Hessian and Web server is very good, with the help of the mature function of Web server, it has great advantage in dealing with a lot of users ' concurrent access, which can be guaranteed by mature Web server in resource allocation, thread queuing, exception handling and so on. RMI itself does not provide multi-threaded servers. Also, RMI needs to open the firewall port, hessian not.
4. Burlap CallBurlap and Hessian are Caucho's open source products, but Hessian in binary mode, 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, burlap call time is 3 times times that of 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 CallHttpinvoker is the Java remote invocation 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. Web Service InvocationThe test uses Apache's axis component as a Web service implementation, and axis is relatively mature in the Web service field. 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 time consuming, the current XML parser efficiency is 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.