Facebook uses FlatBuffers on one billion Android devices
This is a post in an ongoing series on FlatBuffers.
In July, Facebook announced that they use FlatBuffers in their Android apps. In particular, they now use FlatBuffers instead of JSON for client-server communication.
You should go check out the article: it has diagrams showing how FlatBuffers organizes data in memory, and gives insight into the decision-making process that led Facebook to make such a big change.
Here are some of the benefits they mention:
With JSON, the time to parse a Facebook news story was longer than the frame refresh interval. This means that users could experience visual stutter as they scrolled the news feed. FlatBuffers helps to eliminate scroll stutter by loading data faster. (If you’re curious: the frame refresh interval is 16.6ms, JSON was getting parsed in 34ms, and FlatBuffers brought that down to 3ms.)
At app startup, the JSON library required 100-200ms to build a parser. FlatBuffers generates a parser at compile-time, eliminating this delay.
Less pressure on the garbage collector
Using JSON required many short-lived memory allocations, which placed a lot of pressure on the Java garbage collector. FlatBuffers brings transient allocations down to zero.
Simpler app architecture
After switching to FlatBuffers, Facebook found that they could eliminate some internal caching layers.
Since Facebook trusts FlatBuffers for serialization on over 1 billion devices, maybe you’d like to give it a try, too? :-)
About the author
I'm Robert Winslow, a consulting engineer. I help teams launch great products: Learn more.