`
lee79
  • 浏览: 106203 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Java Remoting: Protocol Benchmarks

阅读更多

原帖地址:http://daniel.gredler.net/2008/01/07/java-remoting-protocol-benchmarks/

I’ve been analyzing Java remoting protocols at work over the past couple of days, and thought I’d share some of the results here. Specifically, I’m going to share the results of our protocol benchmarking.

Every application will have different requirements in this area, but most criteria will include performance. At the very least, you will want to know how much (if any) performance you are sacrificing for the sake of your other requirements.

The Protocols

The protocols under consideration are Java’s RMI/JRMP, Oracle’s ORMI (with and without HTTP tunneling enabled), Spring’s HttpInvoker, Caucho’s Hessian and Burlap, and three flavors of Apache XML-RPC (Sun-based, HttpClient-based and Lite-based).

RMI/JRMP is Java’s default binary remoting protocol, and its big advantage is that it supports full object serialization of Serializable and Externalizable objects. RMI/JRMP has historically not been as easy to use as some of the other options, but if you’re using Spring (as we are), it’s as easy to use as anything else (except Apache XML-RPC; see below).

ORMI is OC4J’s EJB remoting protocol, which we’re currently using in production. This protocol was originally developed as part of the Orion application server, whose codebase formed the basis for OC4J. The only differentiator between ORMI and RMI/JRMP is likely to be performance. Of course, this protocol probably won’t be an option unless your serverside component is deployed on OC4J. ORMI supports tunneling via HTTP and HTTPS, should you run into firewall or proxy problems.

Spring’s HttpInvoker is another Java-to-Java binary remoting protocol. It’s also very easy to use and supports full object serialization of Serializable and Externalizable objects. The big difference between HttpInvoker and RMI/JRMP is that HttpInvoker transports data via HTTP, which makes it easier to use when you start running into proxy and firewall issues. Unfortunately, HttpInvoker isn’t an option if you’re not using Spring on both the server and the client.

Caucho’s Hessian protocol is a slim, binary cross-platform remoting protocol. Most cross-platform protocols are XML-based, and thus sacrifice a significant amount of performance in order to achieve interoperability. Hessian’s draw is that it achieves cross-platform interoperability with minimal performance degradation. However, Hessian uses a custom reflection-based serialization mechanism which can be troublesome in certain scenarios (think Hibernate proxies).

Currently in a draft state, Hessian 2 is the second incarnation of the Hessian protocol. You probably don’t want to use it in your production applications quite yet, but it looks very promising. Of course, it’s so easy to switch between Hessian and Hessian 2 that you might want to have a peek just for the heck of it [1].

As far as I can tell, Caucho’s Burlap is essentially Hessian-in-XML. As such, Burlap is not a binary protocol and should be expected to suffer accordingly in the performance department. This being the case, I haven’t been able to figure out exactly why anyone would choose to use Burlap instead of Hessian… aside from a requirement from the marketing department that your RPC be buzzword compliant.

Apache XML-RPC is Apache’s implementation of XML-RPC, an XML-based RPC specification which focuses on interoperability. Apache XML-RPC may be a bit more difficult to set up than the other options if you’re using Spring. The infrastructure for the other protocols is built into the Spring framework, but you’ll have to write the Apache XML-RPC / Spring integration yourself.

Apache XML-RPC supports a number of transport factories under the covers. The three transport factories tested were the default transport factory (based on Sun’s HttpURLConnection), the HttpClient transport factory (based on HttpClient) and the Lite transport factory (based on an Apache XML-RPC minimal HTTP client implementation).

The Configuration

The test consisted of remote invocations to a single method which takes an integer size parameter and returns a list of the specified size. The objects in the returned list each contained 10 instance variables (4 strings of about 40 characters each, 2 dates, 1 long, 1 integer, 1 double and 1 float, none of which were null). The lists returned were static, so there was no list construction overhead.

The results of the first 10 invocations were thrown away, in order to allow the VMs to “warm up.” The next 100 invocations were tallied and averaged.

The tests were performed on a Windows XP SP2 machine with 2GB of RAM and a 2Ghz Core 2 Duo CPU, using Sun’s JVM 1.5.0_09. The client and server were run in two separate VMs on the same host, in order to avoid spurious networking artifacts [2].

The following library versions were used: Spring 2.0.6, Jetty 6.1.5, OC4J 10.1.3.2.0, slf4j 1.4.3, log4j 1.2.14, Apache XML-RPC 3.1, Commons HttpClient 3.1, and Caucho Hessian 3.1.3.

Spring was used on both the clientside and on the serverside in order to hide the remoting details from the interface consumer and implementor. All serverside components were run inside a single Jetty servlet container, except for the ORMI serverside testing components which were run in OC4J.

Vendor extensions and GZIP requesting were enabled for all Apache XML-RPC tests. Streaming and GZIP compressing were enabled for all Apache XML-RPC tests except the Lite tests (the Lite transport factory does not support these options). These configurations represent the best performance optimizations available to the various Apache XML-RPC flavors.

The Results

The following graph illustrates the response times of the various protocols for invocations returning smaller lists:

protocol-benchmark-smaller-lists-3.png

The following graph illustrates the response times of the various protocols for invocations returning larger lists:

protocol-benchmark-larger-lists-3.png

Conclusion

It’s important to note that no general conclusions can be derived from the absolute numbers represented above. Rather, the numbers must be examined relative to each other.

That said, the following observations may be made:

  1. The binary protocols (RMI, ORMI, HttpInvoker and Hessian) are always faster than the XML-based protocols (Burlap and the Apache XML-RPC variants) — except for ORMI with HTTP tunneling enabled.
  2. Performance is pretty even amongst the binary protocols — except for Hessian, which performs well only when compared to the XML-based protocols, and ORMI with HTTP tunneling enabled, which performs on a par with the XML-RPC variants.
  3. Burlap has much better performance than the XML-RPC variants.
  4. Native RMI and Hessian 2 have the best performance until the remote method invocations start returning larger lists, at which point vanilla ORMI takes a slight lead.
  5. Changing Apache XML-RPC’s transport factory does not seem to have a very large effect on performance.
  6. It’s amazing how fast standard ORMI is, compared to ORMI with HTTP tunneling enabled.
  7. Hessian 2 bears watching!

Other Interesting Links

JBoss Remoting Framework Benchmarks: Tom Elrod’s benchmark of the JBoss Remoting framework. Includes part of the Spring Remoting framework.

Nominet’s Protocol Benchmarks: Interesting benchmark of many of the protocols here considered. Intriguingly, HttpInvoker is found to have consistently better performance than RMI/JRMP, a finding which contradicts our results.

Footnotes

[1] If you’re using Spring’s Hessian integration and the latest Hessian JARs, moving to Hessian 2 is as easy as adding the following property to your HessianProxyFactoryBean:

    
        
            
            
        
    

[2] The tests were later run on two separate machines over a controlled network, in order to verify that the local tests are representative; they are.

分享到:
评论

相关推荐

    remoting:詹金斯远程模块

    它包括:基于 TCP 的通信协议、数据序列化、Java 类加载。 该库可在 Jenkins 之外重用。 下载 Jenkins Remoting 库作为 Jenkins 发行版的一部分提供,建议使用那里的版本以确保与您的 Jenkins 实例兼容。 您可以从...

    ares-remoting:mini版dubbo源代码,分布式服务注册与调用原理解释

    《ares-remoting:迷你版Dubbo源代码解析——分布式服务注册与调用揭秘》 在IT行业中,分布式服务已经成为大型系统架构的核心组成部分,而Dubbo作为阿里巴巴开源的一款高性能、轻量级的服务治理框架,备受业界关注...

    Microsoft.NETRemoting:技术概述

    .NETRemoting提供了一种允许对象通过应用程序域与另一对象进行交互的框架。这种框架提供了多种服务,包括激活和生存期支持,以及负责与远程应用程序进行消息传输的通讯通道。格式化程序用于在消息通过通道传输之前,...

    remoting:Jetlang远程处理-异步分布式消息传递

    Jetlang Remoting项目提供用于连接分布式系统的api。 Jetlang为异步分布式消息传递提供了语言不可知的线级协议和线程模型。 该库还包含客户端和服务器Websocket实现。 最新版本可在Maven存储库中获得。 #...

    Fable.Remoting:具有Fable和.NET Apps的F#的类型安全通信层(RPC样式)

    寓言远程处理 Fable.Remoting是Fable和.NET应用程序的通讯层,它抽象了Http和Json,让您仅根据在编译时进行静态检查的纯无状态函数... |> Remoting.fromValue greetingApi 从客户端调用函数 // get a typed-proxy for

    dubbo-2.8.4.jar

    at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.returnFromResponse(DefaultFuture.java:190) at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:110) at ...

    digui.rar_java remoting

    利用rmi远程调用,实现客户端和服务器端的通讯,而不是采用socket的编程方法。

    解决jvmjava.net.BindException: Address already in use: JVM_Bind异常

    【Java中的`java.net.BindException: Address already in use: JVM_Bind`异常】 在Java编程中,当你尝试启动一个服务器端应用,如Tomcat,或者任何需要监听特定端口的服务时,可能会遇到`java.net.BindException: ...

    haxe_remoting:用于 haxe 的其他异步远程处理工具

    异步远程处理类 这个包包括: Node.js 远程连接,一个使用 NodeRelay(感谢 Bruno Garcia),另一个没有。 用于从接口或服务器远程处理类构建异步客户端代理远程处理类的宏。 所有服务器类都被排除在客户端之外。...

    [RDP协议]Remote Desktop Protocol: Basic Connectivity and Graphics Remoting

    远程桌面协议(Remote Desktop Protocol,简称RDP)是由微软开发的一种专用于远程访问的技术,它允许用户通过网络连接并控制另一台计算机。RDP协议不仅支持基本的远程连接功能,还能够提供高质量的图形显示和多媒体...

    DWR js框架 javascript框架 web与java交互 Direct Web Remoting Ajax开源框架

    Direct Web Remoting (DWR) 是一个开源的Java库,它允许Web应用程序在客户端的JavaScript和服务器端的Java之间进行直接的、异步的通信,实现了Web应用中的Ajax功能。DWR通过自动化处理JavaScript和Java之间的类型...

    VB_NET Remoting 高级技术手册

    1. 泛型和Remoting:.NET 2.0及更高版本引入泛型,可以提高Remoting对象的性能和类型安全性。 2. 持久化:通过实现`ISerializable`接口,可以实现远程对象状态的持久化,即使服务器重启也能恢复状态。 3. 自定义...

    Java远程技术.pdf

    - Spring Remoting:Spring框架提供的远程方法调用支持。 - ActiveMQ:一个开源的消息代理和面向消息的中间件。 - Mule ESB:一个开源的企业服务总线。 Java远程技术广泛应用于各种需要远程通信的Java应用开发中...

    Remoting事件(服务端广播改进).

    Remoting事件,特别是服务端广播的改进,是.NET Framework中一项关键的技术,它允许应用程序进行跨进程甚至跨网络的通信。这项技术的核心在于提供了一种透明的方式,使得对象可以像在本地内存中一样在远程进程中操作...

    WCF 与WebService 和Remoting性能比较

    **Remoting:** .NET Remoting是.NET Framework早期版本中的远程调用技术,主要用于.NET应用程序之间的通信。它提供了优化的二进制格式,降低了网络传输的成本,但在跨域、跨平台方面受限,且不支持HTTP,不适用于...

    DWR(Direct Web Remoting)框架jar包.rar

    DWR(Direct Web Remoting)是一个用于改善web页面与Java类交互的远程服务器端Ajax开源框架,可以帮助开发人员开发包含AJAX技术的网站。它可以允许在浏览器里的代码使用行在WEB服务器上的JAVA函数,就像它就在浏览器...

    flex-and-java.zip_flex

    3. ** Pure Java Remoting:** 如果不使用BlazeDS或LCDS,开发者也可以直接使用HTTP、SOAP或RESTful Web服务接口来实现Flex与Java的通信。Flex可以使用HTTPService或WebService组件来调用Java的Web服务接口,通过XML...

Global site tag (gtag.js) - Google Analytics