Description
In this video, we understand how is response data encoded during inter-network communications and also how is it stored on disk?
Sets, Maps, Arrays - they are in-memory data structures. But how can we store them on disks? Python uses in-built pickle module to encode (serialize) data to store them onto disks. But can it be read by a Java client?
Things would have been easy if we used JSON to encode data and store on disks. So why use Pickle?
Actually, we rely on other binary encodings like Google Protobuf, Facebook Thrift for doing this encoding and decoding.
We can serialize the data into protobuf in Python and then parse and read it from a C++ client - no issues!
Plus, we save on the amount of bytes needed to store the data. For a JSON taking 83 bytes on disk, protobuf may need only 33 bytes! Smaller sizes also result in faster inter-server communications. Thus, when a microservice talks to microservice, its common to encode response into protobuf which is then parsed by the reader.
The other benefit with Protobuf is it supports forward and backward compatibility - you can extend and add new keys to your data and old code can work with new data (forward) while new code can work with old data (backward).
One thing to note is Protobuf works well with messages which are few megabytes in size.
References
DDIA Book: https://amzn.to/3B6TJcm
System Design Playlist: https://bit.ly/system-design-course
Google Protobuf: https://developers.google.com/protocol-buffers/docs/overview
Blog1: https://auth0.com/blog/beating-json-performance-with-protobuf/
Blog2: https://betterprogramming.pub/use-binary-encoding-instead-of-json-dec745ec09b6
Sponsored By Educative.io
โ
๐๐ฑ๐๐ฐ๐ฎ๐๐ถ๐๐ฒ.๐ถ๐ผ [46% OFF] ๐๐ปhttps://bit.ly/educative-unlimited-extra-discount
Educative.io coupon "rachit" to get extra discount or use the link above to get "Unlimited" access to "ALL" courses on their websites - React, System Design, Coding Interview in C++, Python, Java, Redux, Docker and what not!
Chapters
00:00 Preview of Google Protobuffers Beating JSON
00:15 Sponsor
00:50 Introduction
1:12 How are Arrays, Sets, Maps Stored on Disk?
1:49 Encoding and Decoding in the Web HTTP Requests
2:36 Encoding Algorithm should support Decoding Algorithm
3:05 Approach A - Encode Everything to JSON!
3:38 Approach B - Binary Encodings Beat JSON for TerraBytes of Data
4:41 File Encoding Should Support Forward and Backward Compatibility
6:50 Where to use JSON?
7:03 MicroService to MicroService - Binary Encodings Are Better
8:10 Demo Comparing JSON Encoding with Google Protobuf
10:09 Comparison of HTTP Response Times - JSON vs Google Protobuf
12:12 How Exactly Google Protobuf is more efficient than JSON encodings?
๐๐ก๐ง๐๐ฅ๐ฉ๐๐๐ช ๐ฃ๐ฅ๐๐ฃ ๐ฃ๐ฅ๐ข๐๐จ๐๐ง๐ฆ
โ
๐๐ฑ๐๐ฐ๐ฎ๐๐ถ๐๐ฒ.๐ถ๐ผ [10% OFF for First 90 Users] ๐๐ปhttps://educative.io/rachit
โ
๐ฆ๐๐๐๐ฒ๐บ ๐๐ฒ๐๐ถ๐ด๐ป [Discount for Indian audience] ๐๐ปhttps://bit.ly/design-rachit
โ
๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด ๐๐ผ๐ผ๐ธ๐ [Amazon Affiliate] ๐๐ปhttps://amazon.in/shop/rachitjain
SUBSCRIBE AND HIT BELL ICON TO CHECK MORE OF MY CONTENT
http://youtube.com/RachitJain?sub_confirmation=1
๐ฆ๐ข๐๐๐๐ ๐ฃ๐ฅ๐ข๐๐๐๐๐ฆ
โ
Portfolio Website - https://rachitiitr.com
โ
Instagram - https://www.instagram.com/rachitiitr
โ
LinkedIn - https://linkedin.com/in/rachitiitr
โ
Twitter - https://twitter.com/rachitiitr
โ
Github - https://github.com/rachitiitr/DataStructures-Algorithms
โ
Facebook - https://fb.me/AlgorithmsWithRachitJain
๐๐ ๐ฃ๐ข๐ฅ๐ง๐๐ก๐ง ๐ฃ๐๐๐ฌ๐๐๐ฆ๐ง๐ฆ
โ
๐๐ผ๐ฑ๐ถ๐ป๐ด ๐๐ป๐๐ฒ๐ฟ๐๐ถ๐ฒ๐ ๐๐ฒ๐ฐ๐๐๐ฟ๐ฒ๐ ๐๐ปhttps://www.youtube.com/watch?v=J1JZjhdr3Oo&list=PLfBJlB6T2eOshO8-LYaMt-Pes1IFojJ_l
โ
๐๐ฟ๐ฎ๐ฝ๐ต ๐ง๐ต๐ฒ๐ผ๐ฟ๐ ๐ฃ๐น๐ฎ๐๐น๐ถ๐๐ ๐๐ปhttps://www.youtube.com/watch?v=xyJxCjweLKE&list=PLfBJlB6T2eOu3dTPKzvAf2axlmQUXGY91
โ
๐++ ๐ฆ๐ง๐ ๐ฃ๐น๐ฎ๐๐น๐ถ๐๐ ๐๐ปhttps://www.youtube.com/watch?v=g-1Cn3ccwXY&list=PLfBJlB6T2eOvyt21CIX_PMmhOgWHiFVab
โ
๐ ๐ ๐ฃ๐ฒ๐ฟ๐๐ผ๐ป๐ฎ๐น ๐๐ป๐๐ฒ๐ฟ๐๐ถ๐ฒ๐ ๐๐
๐ฝ๐ฒ๐ฟ๐ถ๐ฒ๐ป๐ฐ๐ฒ๐ ๐๐ปhttps://www.youtube.com/watch?v=0Vmtmqa9Og0&list=PLfBJlB6T2eOuUAof03sQFlUcrk_Bc7jOA
โ
๐ฃ๐ฟ๐ผ๐ฑ๐๐ฐ๐๐ถ๐๐ถ๐๐ ๐ง๐ถ๐ฝ๐ ๐ฃ๐น๐ฎ๐๐น๐ถ๐๐ ๐๐ปhttps://www.youtube.com/watch?v=0Vmtmqa9Og0&list=PLfBJlB6T2eOuUAof03sQFlUcrk_Bc7jOA
โ
๐๐ถ๐ณ๐ฒ ๐๐ฒ๐๐๐ผ๐ป๐ & ๐ ๐ฒ๐ป๐๐ผ๐ฟ๐๐ต๐ถ๐ฝ ๐๐ปhttps://www.youtube.com/watch?v=9SGM0EqyUc0&list=PLfBJlB6T2eOv8klCHHNVLOmTOIxKu-xzn
๐ฃ๐ฅ๐ข๐๐ฅ๐๐ ๐ ๐๐ก๐ ๐ฃ๐ฅ๐ข๐๐๐๐๐ฆ
โ
Github โบ https://github.com/rachitiitr/DataStructures-Algorithms
โ
Programming Blog โบ http://rachitiitr.blogspot.com
โ
CodeForces โบ http://www.codeforces.com/profile/rachitjain
โ
CodeChef โบ http://www.codechef.com/users/rachitiitr