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                                                                                          ->|

 

你可能感兴趣的:(dubbo dubbo-thrift thrift三种协议直观对比)