Spring的RMI , Http Invoker, Hessian测试结果
RMI配置说明:
1:对象序列化:
public class Account implements Serializable{
private String name;
public String getName(){
return name;
}
public void setName(String name) {
this.name = name;
}
}
2:远程接口定义:
public interface RemoteCallExample extends Remote {
public String show() throws RemoteException;
}
3:远程接口实现:
public class RemoteCallExampleImpl implements RemoteCallExample {
@Override
public String show() throws RemoteException{
return "remote test";
}
}
4:Spring服务器端配置(使用RmiServiceExporter来):
在WEB-INF目录下面新建remoting-servlet.xml文件,添加相关的配置。
5:服务器端类
public class RemoteCallRMI{
public String show() throws RemoteException{
return remoteCallExample.show();
}
private RemoteCallExample remoteCallExample;
public RemoteCallExample getRemoteCallExample() {
return remoteCallExample;
}
public void setRemoteCallExample(RemoteCallExample remoteCallExample) {
this.remoteCallExample = remoteCallExample;
}
}
6:服务器端配置
一些RMI问题说明:
1. RMI在启动配置中需要添加:-Djava.rmi.server.hostname=192.168.100.10
2. 需要制定相关的具体IP,把读取配置文件放到系统启动的时候处理。
Spring3.0后默认的HandlerMapping是DefaultAnnotationHandlerMapping,不是以前的BeanNameUrlHandlerMapping,所以配置Hessian和HttpInvoker的时候需要重新定义一下HandlerMapping.
在按照spring手册配置的时候需要添加定义(Spring文档有遗漏的地方):
测试结果
测试性能:RMI > Hessian > Http Invoker
数据图表如下:
RMI
RMI并发测试(线程池大小:5,线程数:5)
[TestRunner] Starting executor timeOut:1000000ms workers:5 threadPoolSize:5
0 [5,880ms, 100%]
0 [5,881ms, 100%]
0 [5,977ms, 100%]
0 [5,978ms, 100%]
0 [5,989ms, 100%]
RemoteTestNG finishing: 8318 ms
RMI并发测试(线程池大小:5,线程数:10)
[TestRunner] Starting executor timeOut:1000000ms workers:10 threadPoolSize:5
0 [5,843ms, 100%]
0 [5,856ms, 100%]
0 [5,864ms, 100%]
0 [5,967ms, 100%]
0 [5,970ms, 100%]
0 [5,795ms, 100%]
0 [5,810ms, 100%]
0 [5,812ms, 100%]
0 [5,891ms, 100%]
0 [5,935ms, 100%]
RemoteTestNG finishing: 14194 ms
Httpinvoker
并发测试(线程池大小:5,线程数:5)
[TestRunner] Starting executor timeOut:100000ms workers:5 threadPoolSize:5
0 [24,350ms, 100%]
0 [25,384ms, 100%]
0 [27,601ms, 100%]
0 [27,700ms, 100%]
0 [29,443ms, 100%]
RemoteTestNG finishing: 31737 ms
并发测试(线程池大小:5,线程数:10)
[TestRunner] Starting executor timeOut:1000000ms workers:10 threadPoolSize:5
0 [26,519ms, 100%]
0 [26,637ms, 100%]
0 [28,365ms, 100%]
0 [29,744ms, 100%]
0 [29,821ms, 100%]
0 [28,433ms, 100%]
0 [29,914ms, 100%]
0 [31,795ms, 100%]
0 [28,959ms, 100%]
0 [29,407ms, 100%]
RemoteTestNG finishing: 61477 ms
hessian测试结果
并发测试(线程池大小:5,线程数:5)
[TestRunner] Starting executor timeOut:100000ms workers:5 threadPoolSize:5
0 [13,343ms, 100%]
0 [13,957ms, 100%]
0 [14,544ms, 100%]
0 [14,612ms, 100%]
0 [14,822ms, 100%]
RemoteTestNG finishing: 17133 ms
并发测试(线程池大小:5,线程数:10)
[TestRunner] Starting executor timeOut:100000ms workers:10 threadPoolSize:5
0 [13,407ms, 100%]
0 [14,058ms, 100%]
0 [14,271ms, 100%]
0 [14,293ms, 100%]
0 [18,198ms, 100%]
0 [14,496ms, 100%]
0 [15,128ms, 100%]
0 [16,478ms, 100%]
0 [17,680ms, 100%]
0 [17,317ms, 100%]
RemoteTestNG finishing: 37844 ms
需要测试代码的联系:longtask@gmail.com
建议继续学习:
- 解开 phprpc 序列化性能高于 hessian 的秘密 (阅读:4096)
- Spring的BeanFactory体系结构 (阅读:2600)
- 深入浅出jcr之16 该死的RMI,我们需要HTTP+简单RPC协议 (阅读:1842)
- 一起来学 Spring 2.X (阅读:990)
扫一扫订阅我的微信号:IT技术博客大学习
- 作者:longhao 来源: 龙浩的blog
- 标签: Hessian HttpInvoker RMI Spring
- 发布时间:2012-03-12 23:39:12
- [46] 界面设计速成
- [42] Oracle MTS模式下 进程地址与会话信
- [41] 视觉调整-设计师 vs. 逻辑
- [40] IOS安全–浅谈关于IOS加固的几种方法
- [39] android 开发入门
- [38] 图书馆的世界纪录
- [38] 如何拿下简短的域名
- [37] 程序员技术练级攻略
- [37] 【社会化设计】自我(self)部分――欢迎区
- [34] 读书笔记-壹百度:百度十年千倍的29条法则