Serialization – Moving from JSON to Protobuf, Is It Worth It?

serializationwcfweb services

We have REST webservices that can serve XML or JSON (WCF). I'm toying with idea of implementing Protobufs. Why?

PROS

  1. Less load on servers.
  2. Smaller message size – less traffic.
  3. It is easier to switch now than later.

CONS

  1. Need to be implemented
  2. Going to be harder to troubleshoot/sniff messages for debugging.
  3. I can enable GZip on server and JSON will consume as much traffic

What is your suggestion and/or experience on this?

Best Answer

Does the business value of implementing them exceed the cost?

If you implement, you need to change not just your server, but all clients (although you can support both formats and only change clients as needed). That will take time and testing, which is a direct cost. And don't underestimate the time taken to really understand protocol buffers (especially the reasons to make field required or optional), and the time taken to integrate the protobuf compiler into your build process.

So does the value exceed that? Are you faced with a choice of "our bandwidth costs are X% of our revenues and we can't support that"? Or even "we need to spend $20,000 to add servers to support JSON"?

Unless you have a pressing business need, your "pros" aren't really pros, just premature optimization.

Related Topic