As someone who actively develops in Go I completely understand the allure of using protobufs instead of JSON. However I have to protest that for most applications using protobufs is entirely overkill. Even in your examples with the largest payload sizes the difference in time between JSON and protobuf was only 0.5ms, which is insignificant for all but the highest-demand applications. Additionally, using protobufs instead of JSON introduces additional complexity to your code and to your dev/build/deploy process as you now need to generate the necessary protobuf definitions alongside compiling your application.
Additionally, you’re comparing encoding/json
to an optimized third-party package; I would be willing to bet good money that you can make up the performance difference by using an optimized third-party JSON package as well, something like gjson
or jettison
that’s designed for performance.