serialization elco
play

Serialization ELCO Tianjin Dresden Oberstenfeld From the Sensor - PowerPoint PPT Presentation

Serialization ELCO Tianjin Dresden Oberstenfeld From the Sensor to the Human and back again The source of our success Serialization Serialization Table of contents 1. Brief history 2. Serialisation methods in


  1. Serialization

  2. ELCO Tianjin Dresden Oberstenfeld

  3. From the Sensor to the Human and back again The source of our success ฀ ฀ ฀ ฀ ฀ ฀

  4. Serialization

  5. Serialization

  6. Table of contents 1. Brief history 2. Serialisation methods in practice a. Custom b. JSON c. Java.io.Serializable d. Protobuf e. Flatbuffers 3. Benchmarks 4. Conclusion

  7. History ● Serialization exists since start of computer ● 2000: Java Script Object Notation (JSON) sciences first standard 2013 ● YAML in 2001 ● 1980: First standard - Xerox Network Systems Courier RPC ● ProtoBuf 2001-2008 ● 1987: Sun published XDR ● Flatbuffers 2014 ● 1990’s: CORBA, COM, RMI distribute ● 2019: New Java Serialisation? ● Late 1990’s: Bigger memory and http://cr.openjdk.java.net/~briangoetz/amb bandwidths allow human readable formats er/serialization.html (XML)

  8. Serialisation methods

  9. Custom serialization method

  10. NATS NATS documentation: “Unlike traditional messaging systems that use a binary message format that require an API to ● Simple, secure and high performance consume, open source messaging system the text-based NATS protocol makes it easy to implement clients in a wide variety of programming and scripting languages .”

  11. NATS

  12. JSON Douglas Crockford: “It’s not too bad.”

  13. Xi - Editor Raph Levien: I considered binary formats, but the actual ● Text editor (framework) by Raph Levien improvement in performance would be completely in the noise. ● Initially developed for Fuchsia Using JSON considerably lowers friction for developing plug-ins, as it’s available out of the ● Micro service architecture box for most modern languages, and there are plenty of the libraries available for the other ones.

  14. IoTHub Developer Use case: ● Usage in REST API and for unknown data structures ● Transfer a SQL result set between Golang and JavaScript ● Encoding/Decoding in most language available ● Having test validating handling ● Handling differs from language to ● Some code ... language ● Best usage in JS

  15. Java Serializable “He [Mark Reinhold] estimates that at least a third —maybe even half— of Java vulnerabilities have involved serialization”

  16. Stream magic

  17. Stream version

  18. Flag for new object

  19. Flag for new class

  20. Length of class name

  21. class name

  22. Serial version id

  23. Some flags

  24. No of fields in class

  25. Type of first field

  26. Length of field name

  27. Name of field

  28. Field content of title field

  29. Protobuf language-neutral, platform-neutral extensible mechanism for serializing structured data

  30. Type and number of field

  31. Value of field 1 (118)

  32. Type and number of field

  33. Length of string

  34. Value of second field

  35. Elco IoTHub Reasons for Protobuf: ● Industrial IoT Platform ● Small messages ● Micro service architecture ● Fast (for our use case) ● Services written in Go, NodeJs, C# ● Language independent ● Protobuf used for service to service ● Build in versioning communication and persistence ● Big community

  36. IoTHub Developer Use case: ● Usage in gRPC between agents and IoTHub ● Agent - Gateway communication ● Big amount of generated code ● Gateway service with two functions ● In some cases hard work with IDEs ● Some code ... (Goland vs. Ryder) ● But usage is not complex

  37. Flatbuffers language-neutral, platform-neutral extensible mechanism for serializing structured data

  38. Position of root table = 20

  39. Rel. position of vtable = -14

  40. Size of vtable = 20

  41. Object size

  42. Relative position of first field (id = 20)

  43. Value of field id = 118

  44. Relative position of second field (name = 12)

  45. Relative position of value of second field (name = 12) Length of value

  46. Facebook - Android ● Segments of social graph stored on Reasons for Flatbuffers: devices ● Story load time from disk cache is reduced from 35 ms to 4 ms per story ● Transient memory allocations are reduced by 75 percent ● Cold start time is improved by 10-15 percent ● We have reduced storage size by 15 percent

  47. IoTHub Developer ● Usage as communication protocol Use case: between JavaScript (V8) and GoLang ● SQL Select query ● Similar handling in the different target languages ● Sql.query(db, "SELECT * FROM person;") ● Strings, vectors need some effort ● Some code ... preparing serialization ● Deserialization on the other side is simple ● Access to single fields without dedicated deserialization step

  48. Benchmarks

  49. Benchmarks Flatbuffers > Protocol Buffers > JSON https://google.github.io/flatbuffers/flatbuffers_benchmarks.html

  50. Benchmarks Protocol Buffers > FlatBuffers >> JSON https://github.com/alecthomas/go_serialization_benchmarks

  51. Benchmarks Protocol Buffers = FlatBuffers > JSON https://github.com/smallnest/gosercomp

  52. XI - Editor

  53. Conclusion

  54. Conclusion Is it: ● Available for your programming language? ● Nice to use? ● Good to integrate into CI? ● Maintained? ● Made for your use Does it fit your case? 3. requirements? 1. Choose one of: 2. Benchmark JSON, Flatbuffers, Protobuf, Test it for your 4. Use it! Thrift, Avro, Custom, etc. it! yes specific use yes case! no no

  55. Thanks for listening!

  56. Sources ● https://en.wikipedia.org/wiki/Comparison_of_data-serialization_f ● https://developers.google.com/protocol-buffers/docs/encodin ormats g ● https://nats-io.github.io/docs/nats_protocol/nats-protocol.html ● https://developers.google.com/protocol-buffers/docs/proto3 ● https://nats-io.github.io/docs/developer/concepts ● https://github.com/mzaks/FlatBuffersSwift/wiki/FlatBuffers-Ex ● Douglas Crockford: The JSON Saga, plained https://www.youtube.com/watch?v=-C-JoyNuQJs ● https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.ht ● The Post JavaScript Apocalypse - Douglas Crockford, ml https://www.youtube.com/watch?v=NPB34lDZj3E ● https://google.github.io/flatbuffers/flatbuffers_internals.html ● Xi: an editor for the next 20 years, ● https://google.github.io/flatbuffers/flatbuffers_white_paper.ht https://www.recurse.com/events/localhost-raph-levien ml ● https://github.com/xi-editor/xi-editor ● https://google.github.io/flatbuffers/flatbuffers_benchmarks.ht ● https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.ht ml ml ● https://code.fb.com/android/improving-facebook-s-performan ● http://cr.openjdk.java.net/~briangoetz/amber/serialization.html ce-on-android-with-flatbuffers/ ● https://www.javaworld.com/article/2072752/the-java-serialization ● https://github.com/alecthomas/go_serialization_benchmarks -algorithm-revealed.html ● https://github.com/smallnest/gosercomp ● https://www.infoworld.com/article/3275924/oracle-plans-to-dump -risky-java-serialization.html ● https://developers.google.com/protocol-buffers/docs/overview#a -bit-of-history

Recommend


More recommend