dubbo dubbo-thrift thrift三种协议直观对比

最近在研究学习dubbo源码,下面对比一下dubbo dubbo-thrift thrift三种协议序列化后报文体积:

远程调用一个简单方法:Hello.hello("哈哈哈");


    dubbo:{ -38, -69, -62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -48, 5, 50, 46, 48, 46, 48, 48,  
                    33, 99, 111, 109, 46, 100, 117, 98, 98, 111, 46, 97, 112, 112, 115, 46, 116, 104, 114, 105, 102, 116,  
                    46, 72, 101, 108, 108, 111, 36, 73, 102, 97, 99, 101, 5, 48, 46, 48, 46, 48, 11, 104, 101, 108, 108,  
                    111, 83, 116, 114, 105, 110, 103, 18, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83, 116, 114,  
                    105, 110, 103, 59, 8, -27, -109, -120, -27, -109, -120, 111, 111, 111, 111, 111, 111, 72, 4, 112, 97,  
                    116, 104, 48, 33, 99, 111, 109, 46, 100, 117, 98, 98, 111, 46, 97, 112, 112, 115, 46, 116, 104, 114,  
                    105, 102, 116, 46, 72, 101, 108, 108, 111, 36, 73, 102, 97, 99, 101, 9, 105, 110, 116, 101, 114, 102,  
                    97, 99, 101, 48, 33, 99, 111, 109, 46, 100, 117, 98, 98, 111, 46, 97, 112, 112, 115, 46, 116, 104, 114,  
                    105, 102, 116, 46, 72, 101, 108, 108, 111, 36, 73, 102, 97, 99, 101, 7, 116, 105, 109, 101, 111, 117,  
                    116, 7, 54, 48, 48, 48, 48, 48, 48, 7, 118, 101, 114, 115, 105, 111, 110, 5, 48, 46, 48, 46, 48, 90 };  
      
    dubbo_thrift : { 0, 0, 0, 97, -38, -68, 0, 0, 0, 97, 0, 54, 1, 0, 0, 0, 33, 99, 111, 109, 46,  
                    100, 117, 98, 98, 111, 46, 97, 112, 112, 115, 46, 116, 104, 114, 105, 102, 116, 46, 72, 101, 108, 108,  
                    111, 36, 73, 102, 97, 99, 101, 0, 0, 0, 0, 0, 0, 0, 0, -128, 1, 0, 1, 0, 0, 0, 11, 104, 101, 108, 108,  
                    111, 83, 116, 114, 105, 110, 103, 0, 0, 0, 1, 11, 0, 1, 0, 0, 0, 12, -27, -109, -120, -27, -109, -120,  
                    111, 111, 111, 111, 111, 111, 0 };  
      
    thrift:{ -128, 1, 0, 1, 0, 0, 0, 11, 104, 101, 108, 108, 111, 83, 116, 114, 105, 110, 103,  
                    0, 0, 0, 1, 11, 0, 1, 0, 0, 0, 12, -27, -109, -120, -27, -109, -120, 111, 111, 111, 111, 111, 111, 0 };  

显而易见,dubbo协议体积是最大的。实际上,dubbo协议是对hession进行一定的改良。报文体积大的其中一个原因是协议里面附加了较多信息,比如版本号,接口名字,参数类型等。另一个重要原因是dubbo把调用对象或返回结果,直接整个序列化。

 

dubbo-thrift协议,在thrift原生协议前增加了一些头信息,但信息量不大:

 

 * |<-                                  message header                                                                  ->|<- message body ->|
 * +----------------+----------------------+------------------+---------------------------+-----------------------------------------+
 * | magic (2 bytes)|message size (4 bytes)|head size(2 bytes)| version (1 byte) | header |   message body   |
 * +----------------+----------------------+------------------+---------------------------+-----------------------------------------+
 * |<-                                               message size                                                                                          ->|



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值