Beyond JSON - An Introduction to FlatBuffers
-
Upload
maxim-zaks -
Category
Software
-
view
585 -
download
3
Transcript of Beyond JSON - An Introduction to FlatBuffers
![Page 1: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/1.jpg)
Maxim Zaks
Beyond JSON - An Introduction to FlatBuffers
![Page 2: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/2.jpg)
Agenda
• About me
• The Why and How of Data Serialisation
• Deep dive into FlatBuffers
![Page 3: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/3.jpg)
RESI News - Nachrichten, die Spaß machen
![Page 4: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/4.jpg)
![Page 5: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/5.jpg)
![Page 6: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/6.jpg)
VS.
![Page 7: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/7.jpg)
Why do we need data serialisation?
• Persisting State
• Machine to Machine Communication
• Representation of Configuration
![Page 8: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/8.jpg)
How can we persist data on mobile?
• Custom binary representation
• Language provided binary serialisation
• Text based representation
• CSV, XML, JSON, YAML
• Embedded SQL or NoSQL DB
• Binary cross platform serialisation library
• FlatBuffers, Protocol Buffers, Cap’n Proto, SBE, Apache Thrift
![Page 9: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/9.jpg)
Important criteria for persisting data
• Size on disk
• Speed of read & write / partial read / memory consumption
• Human readable and writable
• Support of OO language type system
• Data versioning / evolution / migration
![Page 10: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/10.jpg)
VS.
![Page 11: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/11.jpg)
JSON
• Size on disk 👍👎
• Speed of read & write / partial read / memory consumption 👎
• Human readable and writable 👍 👍
• Support of OO language type system 👍👎
• Data versioning / evolution / migration 👍👎
![Page 12: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/12.jpg)
FlatBuffers
• Size on disk 👍👎
• Speed of read & write / partial read / memory consumption 👍 👍
• Human readable and writable 👍👎
• Support of OO language type system 👍 👍
• Data versioning / evolution / migration 👍 👍
![Page 13: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/13.jpg)
JSON FlatBuffers
size on disk 👍👎 👍👎
read & write performance 👎 👍👍
human readable & writable 👍👍 👍👎
typed API 👍👎 👍👍
multi version support 👍👎 👍👍
![Page 14: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/14.jpg)
But what about sending data?
![Page 15: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/15.jpg)
Important criteria for sending data
• Size on disk wire
• Speed of read & write / partial read / memory consumption
• Human readable and writable
• Support of OO language type system
• Data versioning / evolution / migration
![Page 16: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/16.jpg)
Enough theorylet’s do some practice
![Page 17: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/17.jpg)
FlatBuffers IDL
![Page 18: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/18.jpg)
./flatc -n person.fbs
![Page 19: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/19.jpg)
FlatBuffers Schema Editor
![Page 20: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/20.jpg)
FlatBuffers IDL
![Page 21: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/21.jpg)
FlatBuffers IDL
![Page 22: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/22.jpg)
FlatBuffers IDL
![Page 23: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/23.jpg)
FlatBuffers IDL
![Page 24: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/24.jpg)
![Page 25: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/25.jpg)
![Page 26: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/26.jpg)
![Page 27: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/27.jpg)
![Page 28: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/28.jpg)
![Page 29: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/29.jpg)
![Page 30: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/30.jpg)
What does it all mean in practice?
![Page 31: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/31.jpg)
Size on disk / wire
![Page 32: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/32.jpg)
Speed of read, writeand memory allocation
![Page 33: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/33.jpg)
![Page 34: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/34.jpg)
![Page 35: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/35.jpg)
Partial Read
![Page 36: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/36.jpg)
• over 3M cities
• ≈200 MB
• real time search
• in memory
• from file 10x slower
![Page 37: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/37.jpg)
Human readable & writable is a manner of tooling
• ./flatc -b person.fbs person.json
• ./flatc -t person.fbs -- person.bin --raw-binary --strict-json
![Page 38: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/38.jpg)
Support of OO Language type system
![Page 39: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/39.jpg)
![Page 40: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/40.jpg)
Data is backwards & forwards compatible
![Page 41: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/41.jpg)
More information
• https://google.github.io/flatbuffers/
• https://github.com/mzaks/FlatBuffersSchemaEditor
• https://github.com/mzaks/FlatBuffersSwift
• https://twitter.com/iceX33
![Page 42: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/42.jpg)
Questions?
![Page 43: Beyond JSON - An Introduction to FlatBuffers](https://reader033.fdocuments.in/reader033/viewer/2022042605/5889ae661a28aba54d8b4e59/html5/thumbnails/43.jpg)
Thank you!