Avro与Protobuf性能对比
所用Schema
Avro所用Schema
{"namespace": "test.avro",
"type": "record",
"name": "User",
"fields": [
{"name": "i", "type": ["int","null"]},
{"name": "l", "type": ["long", "null"]},
{"name": "s", "type": ["string", "null"]},
{"name":"b","type":["boolean","null"]}
]
}
Protobuf所用Schema
message SomeData {
optional int32 i = 1;
optional int64 l = 2;
optional string s = 3;
optional bool b=4;
}
写出的数据:
{
"i" : random,
"l" : random,
"s" : "never",
"b" : random
}
测试对象:
- 用
protoc
将 Protobuf Schema编译成java类来进行操作 - 用
DynamicMessage
动态生成所需的数据结构来进行 Protobuf 的序列化操作 - 用
GenericMessage
根据Avro的定义文件解析出来的Schema进行操作 - 用
GenericMessage
根据动态生成的Schema进行操作