Search code examples
restprotocol-buffersmicroservices

Is protobuf a good choice for external microservice? By external microservice I mean some service that is exposed as a RESTful endpoint


If protobuf is used as a data serialization for external microservice that serves a RESTful endpoint, the protobuf message needs to converted back to JSON message, which will increase the overall message response time.

I know protobuf is good for communication between internal services, but is it good for external services as well?


Solution

  • An external API is : whatever the external API is. If that external API is gRPC, then protobuf is a great choice, as that is virtually always what gRPC uses (you need to really try hard to use something other than protobuf with gRPC). gRPC is not ubiquitous, but nor is it uncommon for inter-business APIs (especially if one end is Google, obviously).

    Having to translate a message between different shapes (whether that be entirely different formats, or different payloads in the same format) is fairly normal, assuming you're not simple a pass-thru proxy, so: having to decode and encode isn't a major shocker. If you can make at least one of those steps have the size and speed benefits of protobuf: then great.