Serialization
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    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 many of JSON’s 48 bytes are actually your order?

      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.

          1. 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:

          2. 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:

          3. Deep dive 3 of 4

            Interviewer

            “Your orders topic 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:

          4. Deep dive 4 of 4

            Interviewer

            “Order events carry amount in 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.