It can be a demanding ask for you to decide between two great options. Case in point - ProtoBuf or JSON.
From my experience, the decision boils down to following:
1. Is the messaging contract between two parties strict?
winner: protobuf.
protobuf expects folks to work with an Interface Definition Language (IDL) and produce a .proto file. Once the file is ready, both parties need to generate their platform specific proxies from the .proto file and generated code should not be modified.
json is a little liberal format and does not force a schema by itself. There are tools available to force a json schema but json serialization process does not force schema validation itself. It is always an added step and is performed by referencing another 3rd party (and may be not free) library.
2. What is the expectations around speed of serialization/deserialization?
winner: protobuf
3. What is the expectation around size of serialized data?
winner: protobuf
4. What is the expectation around readability of serialized data?
winner: json
5. What is the application?
winner: json (web applications, web apis, dynamic data type requirements.)
winner: protobuf (low latency scenarios, high throughput etc.)
reference: http://maxondev.com/serialization-performance-comparison-c-net-formats-frameworks-xmldatacontractserializer-xmlserializer-binaryformatter-json-newtonsoft-servicestack-text/
http://ganges.usc.edu/pgroupW/images/a/a9/Serializarion_Framework.pdf
From my experience, the decision boils down to following:
1. Is the messaging contract between two parties strict?
winner: protobuf.
protobuf expects folks to work with an Interface Definition Language (IDL) and produce a .proto file. Once the file is ready, both parties need to generate their platform specific proxies from the .proto file and generated code should not be modified.
json is a little liberal format and does not force a schema by itself. There are tools available to force a json schema but json serialization process does not force schema validation itself. It is always an added step and is performed by referencing another 3rd party (and may be not free) library.
2. What is the expectations around speed of serialization/deserialization?
winner: protobuf
3. What is the expectation around size of serialized data?
winner: protobuf
4. What is the expectation around readability of serialized data?
winner: json
5. What is the application?
winner: json (web applications, web apis, dynamic data type requirements.)
winner: protobuf (low latency scenarios, high throughput etc.)
http://ganges.usc.edu/pgroupW/images/a/a9/Serializarion_Framework.pdf
No comments:
Post a Comment