Search code examples
restflatbuffers

Opinions on using Flatbuffer in REST


I was wondering what the general opinion was about using different serialization methods for REST APIs. JSON and XML are the most popular but I was wondering if serialization in Flatbuffers might be a possible alternative.

Deserialization on the server side is technically cheaper than JSON (the big win is "zero-copy" reads and fast serialization responses on larger servers). On the client browser FB serialization would be slower than JSON (JSON serial/deserial is implemented natively) but I think that's minor given that the datasets are extremely small the user wouldn't notice a difference anyways.

I imagine REST purists would say this is taboo. The downsides would be:

  1. Tooling for reading FB in REST isn't quite there
  2. Client-side performance with larger datasets isn't as performant
  3. MIME type sent would be application/octet since FB doesn't have its own MIME yet

This thought came from the fact that I'm using FB in gRPC and now have to accept requests via browser. Transforming from REST adds an extra serialization step (if I took a similar approach to using gRPC-Web).


Solution

  • There is nothing about REST that specifically dictates or suggest any mimetype. REST predates JSON, so purists definitely should not call this taboo =)