1. 程式人生 > >HSF和Dubbo有什麽區別

HSF和Dubbo有什麽區別

rec string meta unit client 描述 模型 最新 這一

一、 以下摘錄自企業級分布式應用服務EDAS官網段落
RPC服務

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

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

二、

dubbo和S-HSF測試對比

轉載 :http://www.cnblogs.com/langtianya/p/5720275.html#undefined 今天沒什麽事,簡單測試下RPC框架性能: HSF完勝dubbo


1.dubbo測試結果:

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

同步模型

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

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


2.hsf 測試結果:

異步模型:

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

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


同步模型:

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

HSF和Dubbo有什麽區別