技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> 系统运维 --> Spring的RMI , Http Invoker, Hessian测试结果

Spring的RMI , Http Invoker, Hessian测试结果

浏览:1975次  出处信息

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

建议继续学习:

  1. 解开 phprpc 序列化性能高于 hessian 的秘密    (阅读:4084)
  2. Spring的BeanFactory体系结构    (阅读:2592)
  3. 深入浅出jcr之16 该死的RMI,我们需要HTTP+简单RPC协议    (阅读:1839)
  4. 一起来学 Spring 2.X    (阅读:979)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1