Protocol Buffers versus JSON or BSON

This post compares serialization speeds and sizes in .NET, including JSON, BSON and XML.

alt text

alt text

http://james.newtonking.com/archive/2010/01/01/net-serialization-performance-comparison.aspx


Thrift is another Protocol Buffers-like alternative as well.

There are good benchmarks from the Java community on serialization/deserialization and wire size of these technologies: https://github.com/eishay/jvm-serializers/wiki

In general, JSON has slightly larger wire size and slightly worse DeSer, but wins in ubiquity and the ability to interpret it easily without the source IDL. The last point is something that Apache Avro is trying to solve, and it beats both in terms of performance.

Microsoft has released a C# NuGet package Microsoft.Hadoop.Avro.


Here are some recent benchmarks showing the performance of popular .NET Serializers.

The Burning Monks benchmarks show the performance of serializing a simple POCO whilst the comprehensive Northwind benchmarks show the combined results of serializing a row in every table of Microsoft's Northwind dataset.

enter image description here

Basically protocol buffers (protobuf-net) is around 7x quicker than the fastest Base class library Serializer in .NET (XML DataContractSerializer). Its also smaller than the competition as it is also 2.2x smaller than Microsofts most compact serialization format (JsonDataContractSerializer).

ServiceStack's Text serializers are the closest to matching the performance of the binary protobuf-net where its Json Serializer is only 2.58x slower than protobuf-net.