Search code examples
c++protocol-buffersflatbuffers

Protocol Buffers vs Flat Buffers


So, I'm currently working on a project where Protocol Buffers is used extensively, mainly as a way to store complex objects in a key-value database.

Would a migration to Flat Buffers provide a considerable benefit in terms of performance?

More in general, is there ever a good reason to use Protocol Buffers instead of Flat Buffers?


Solution

  • Protocol buffers are optimized for space consumption on the wire, so for archival and storage, they are very efficient. However, the complex encoding is expensive to parse, and so they are computationally expensive, and the C++ API makes heavy use of dynamic allocations. Flat buffers, on the other hand, are optimized for efficient parsing and in-memory representation (e.g. offering zero-copy views of the data in some cases).

    It depends on your use case which of those aspects is more important to you.