HSF和Dubbo有什么区别

àì夳堔傛蜴生んèń 2022-01-18 23:33 338阅读 0赞

一、

以下摘录自企业级分布式应用服务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. 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

测试数据:

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. // 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() {
  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. }
  44. 同步模型:

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

    Java代码 收藏代码

    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() {
    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. }

发表评论

表情:
评论列表 (有 0 条评论,338人围观)

还没有评论,来说两句吧...

相关阅读

    相关 ==equals()什么区别

    1.基本数据类型和引用数据类型==的比较作用效果是不同的 1)基本数据类型 = =比较的是值是相同 2)引用数据类型 = =比较的是引用的地址是都相同 2.equa