HSF和Dubbo有什麼區別

一、

以下摘錄自企業級分佈式應用服務EDAS官網段落

RPC服務

提供對Dubbo和HSF兩個RPC框架的支持。阿里巴巴第一代RPC框架Dubbo是國內第一款成熟的商用級RPC框架,已於2011年正式對外開源,目前已發展成爲國內開源價值最高、用戶使用規模最大的開源軟件之一。最新一代RPC框架HSF,全稱High Speed Framework,也叫"好舒服","很舒服"框架,是阿里內部對這一款高性能服務框架的暱稱,是一款面向企業級互聯網架構量身定製的分佈式服務框架。HSF以高性能網絡通信框架爲基礎,提供了諸如服務發佈與註冊,服務調用,服務路由,服務鑑權,服務限流,服務降級和服務調用鏈路跟蹤等一系列久經考驗的功能特性。

來源:企業級分佈式應用服務EDAS_企業雲計算解決方案

 

 

二、

dubbo和S-HSF測試對比

 今天沒什麼事,簡單測試下RPC框架性能: HSF完勝dubbo 


1.dubbo測試結果: 

note: 
dubbo測試時有使用ZooKeeper,所以存在不公平性,不一定準確。 

同步模型 

耗時:16.808 s 
平均:0.16808 ms 
TPS:5949.547834364588 

測試數據: 

Java代碼  收藏代碼

  1. public class TPS_TEST {  
  2.   
  3.     public static void main(String[] args) throws InterruptedException {  
  4.         final ClassPathXmlApplicationContext context =   
  5.                 new ClassPathXmlApplicationContext(  
  6.                         new String[] {"file:E:/1-project_test/dubbox-master/dubbo-demo/dubbo-demo-consumer/src/main/resources/META-INF/spring/dubbo-demo-consumer.xml"});  
  7.         final HelloService helloService = (HelloService)context.getBean("helloService"); // get service invocation proxy  
  8.         ExecutorService executorServicePool = Executors.newFixedThreadPool(200);  
  9.         final int size = 100000;  
  10.         final CountDownLatch cdl = new CountDownLatch(size);  
  11.         long begin = System.currentTimeMillis();  
  12.         for (int i = 0; i < size; i++) {  
  13.             executorServicePool.execute(new Runnable() {  
  14.                 @Override  
  15.                 public void run() {  
  16.                     try {  
  17.                           
  18.                         String hello = helloService.hello("aa"); // do invoke!  
  19.                         //System.out.println( hello ); // cool, how are you~  
  20.                         cdl.countDown();  
  21.                     } catch (Exception e) {  
  22.                         e.printStackTrace();  
  23.                     }  
  24.                 }  
  25.             });  
  26.         }  
  27.         //executorServicePool.shutdown();  
  28.         //executorService.awaitTermination(10, TimeUnit.MINUTES);  
  29.         cdl.await();//等待所有任務處理完  
  30.         long time = System.currentTimeMillis() - begin;  
  31.         System.out.println("耗時:" + (double) time / 1000 + " s");  
  32.         System.out.println("平均:" + ((double) time) / size +" ms");  
  33.         System.out.println("TPS:" + (double) size / ((double) time / 1000));                
  34.      
  35.       
  36.     }  
  37.   
  38.      
  39. }  



2.hsf 測試結果: 

異步模型: 

耗時:6.305 s 
平均:0.06305 ms 
TPS:15860.428231562253 

測試數據: 

Java代碼  收藏代碼

  1. public class Client {  
  2.     public static void main(String[] args) throws InterruptedException, ExecutionException {  
  3.         final int size = 100000;  
  4.         final CountDownLatch cdl = new CountDownLatch(size);  
  5.   
  6.         // final TestService testService = ServiceProxyFactory.getRoundFactoryInstance(connector).wrapAsyncProxy(  
  7.         // TestService.class);  
  8.           
  9.         HsfConnector connector = new HsfConnectorImpl();  
  10.         connector.connect(new InetSocketAddress("localhost", 8082));  
  11.           
  12.           
  13.         final TestService testService = ServiceProxyFactory.getRoundFactoryInstance(connector).wrapAsyncCallbackProxy(  
  14.                 TestService.class, new AsyncCallback<Object>() {  
  15.                     public void doCallback(Object data) {  
  16.                         //System.out.println("received:" + data);  
  17.                         cdl.countDown();  
  18.                     };  
  19.                     @Override  
  20.                     public void doExceptionCaught(Throwable ex, HsfChannel channel, Object param) {  
  21.                         System.out.println(ex);  
  22.                         super.doExceptionCaught(ex, channel, param);  
  23.                     }  
  24.                 });  
  25.         ExecutorService executorServicePool = Executors.newFixedThreadPool(200);  
  26.         long begin = System.currentTimeMillis();  
  27.         for (int i = 0; i < size; i++) {  
  28.             executorServicePool.execute(new Runnable() {  
  29.                 @Override  
  30.                 public void run() {  
  31.                     try {  
  32.                         testService.test("aa");  
  33.                     } catch (Exception e) {  
  34.                         e.printStackTrace();  
  35.                     }  
  36.                 }  
  37.             });  
  38.         }  
  39.         //executorServicePool.shutdown();  
  40.         //executorService.awaitTermination(10, TimeUnit.MINUTES);  
  41.         cdl.await();//等待所有任務處理完  
  42.         long time = System.currentTimeMillis() - begin;  
  43.         System.out.println("耗時:" + (double) time / 1000 + " s");  
  44.         System.out.println("平均:" + ((double) time) / size +" ms");  
  45.         System.out.println("TPS:" + (double) size / ((double) time / 1000));  
  46.           
  47.     }  
  48.   
  49. }  



同步模型: 

耗時:9.446 s 
平均:0.09446 ms 
TPS:10586.491636671608 

Java代碼  收藏代碼

  1. //tips:  
  2. //模擬HSF的同步模型:在10萬個併發線程發送數據時有時候比異步模型還要快,這點有點想不通,估計是我測試的服務是直接return的場景吧。  
  3.   
  4. /** 
  5.  * @Title: Client.java 
  6.  * @Description: TODO(添加描述) 
  7.  * @date 2012-2-23 上午01:01:33 
  8.  * @version V1.0 
  9.  */  
  10. public class Client2 {  
  11.     public static void main(String[] args) throws InterruptedException, ExecutionException {  
  12.          final int size = 100000;    
  13.          final CountDownLatch cdl = new CountDownLatch(size);     
  14.          HsfConnector connector = new HsfConnectorImpl();    
  15.          connector.connect(new InetSocketAddress("10.118.63.12", 10223));    
  16.                 
  17.                 
  18.         /* 
  19.          final TestService testService = ServiceProxyFactory.getRoundFactoryInstance(connector).wrapAsyncCallbackProxy(   
  20.                 TestService.class, new AsyncCallback<Object>() {   
  21.                     public void doCallback(Object data) {   
  22.                         //System.out.println("received:" + data);   
  23.                         cdl.countDown();   
  24.                     };   
  25.                     @Override   
  26.                     public void doExceptionCaught(Throwable ex, HsfChannel channel, Object param) {   
  27.                         System.out.println(ex);   
  28.                         super.doExceptionCaught(ex, channel, param);   
  29.                     }   
  30.                 });   
  31.          ExecutorService executorServicePool = Executors.newFixedThreadPool(200);   
  32.                 long begin = System.currentTimeMillis();   
  33.                 for (int i = 0; i < size; i++) {   
  34.                     executorServicePool.execute(new Runnable() {   
  35.                         @Override   
  36.                         public void run() {   
  37.                             try {   
  38.                                 testService.test("aa");   
  39.                             } catch (Exception e) {   
  40.                                 e.printStackTrace();   
  41.                             }   
  42.                         }   
  43.                     });   
  44.                 }  
  45.                  
  46.           */  
  47.            
  48.          final TestService testService = ServiceProxyFactory.getRoundFactoryInstance(connector).wrapSyncProxy(    
  49.                 TestService.class);   
  50.            
  51.         ExecutorService executorServicePool = Executors.newFixedThreadPool(200);    
  52.         long begin = System.currentTimeMillis();    
  53.         for (int i = 0; i < size; i++) {    
  54.             executorServicePool.execute(new Runnable() {    
  55.                 @Override    
  56.                 public void run() {    
  57.                     try {    
  58.                         String hello = testService.test("aa");    
  59.                         cdl.countDown();    
  60.                     } catch (Exception e) {    
  61.                         e.printStackTrace();    
  62.                     }    
  63.                 }    
  64.             });    
  65.         }    
  66.         //executorServicePool.shutdown();    
  67.         //executorService.awaitTermination(10, TimeUnit.MINUTES);    
  68.         cdl.await();//等待所有任務處理完    
  69.         long time = System.currentTimeMillis() - begin;    
  70.         System.out.println("耗時:" + (double) time / 1000 + " s");    
  71.         System.out.println("平均:" + ((double) time) / size +" ms");    
  72.         System.out.println("TPS:" + (double) size / ((double) time / 1000));   
  73.       
  74.     }  
  75.       
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章