Layer 3 · Go deeper · 9 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Back of the envelope
Size it up
Tap through each step of the arithmetic.
How much does gzip close the gap between JSON and Avro?
How far past JavaScript’s safe integers do 64-bit IDs reach?
Build-up · 5 steps
Shrink one order from 48 to 10 bytes
One Swiggy-style order, id 1500, status PAID, amount_paise 49900 (₹499). Watch the field names turn into numbers, then disappear.
Step 1 of 5
JSON: names in every record
Minified, the order is 48 bytes, and only 13 are values. Key names, quotes, braces, colons and commas take the other 35, in every single record.
4 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 4
Interviewer
“Several teams write Python pickles to a shared job queue, and your worker unpickles whatever arrives. What do you change?”
Your move. Pick an approach:
Deep dive 2 of 4
Interviewer
“Your food-delivery app’s public order API serves phones and partner integrations. Which wire format do you choose?”
Your move. Pick an approach:
Deep dive 3 of 4
Interviewer
“Your
orderstopic keeps events for a year, and new consumers replay it from offset 0. How do you keep every version readable?”Your move. Pick an approach:
Deep dive 4 of 4
Interviewer
“Order events carry
amountin rupees. Billing now wants paise, and services deploy independently. What do you do?”Your move. Pick an approach:
Build-up · 5 steps
Ship a new schema through the registry
Checkout adds an optional tip_paise to its Avro order events. Follow schema v2 from registration to the billing consumer reading its first v2 record.
Step 1 of 5
Add a field, with a default
A union with null first and a default of null is how Avro adds an optional field. Without the default, new readers can’t read old data.