CSE Roadmap

Common tier · about 3 hours · 8 parts

Part 8 of 8 · 3 min read

Exercises

Easy

Easy 1: Size the formats (20 minutes)

A message is sent 200 million times a day. Using the sizes in the table of section 3, compute the daily volume in GB for JSON, MessagePack and Avro, and the saving of Avro compared with JSON in percent.

Done when: three volumes and a percentage.

Hint

Messages × bytes, then convert to GB.

Easy 2: Safe or unsafe (20 minutes)

For a Protocol Buffers schema, mark each change safe or unsafe: rename a field, change a tag number, add an optional field, add a required field, remove an optional field and reuse its number.

Done when: six verdicts, each with one reason.

Hint

Tags identify fields in the bytes; names do not appear.

Easy 3: Which direction (20 minutes)

New code reads old data: which compatibility? Old code reads new data: which? A phone app from last year talks to a new server: which direction does the server's reply need?

Done when: three answers with reasons.

Hint

Think "who wrote, who reads".

Medium

Medium 1: Avro by hand (30 minutes)

Writer schema: id, name, age. Reader schema: id, name, city (default "unknown"). Show what the reader sees for a record written as (7, "Asha", 31). Then reverse writer and reader.

Done when: two decoded results with the rule used for each field.

Hint

Match by name. Missing in the writer means default. Missing in the reader means ignore.

Medium 2: Plan the rename (30 minutes)

A JSON message field fullName must become displayName. 12 services read it, and a mobile app from the last two years also reads it. Write the steps to rename it without breaking anything, with releases and waiting periods.

Done when: at least four steps in order, and a condition for moving to each.

Hint

Readers first, writers second, removal last.

Medium 3: Cost of base64 (30 minutes)

A service sends 2 million images a day of 250 KB each inside JSON as Base64. Compute the daily volume as raw bytes and as Base64. Propose a change and the volume after it.

Done when: two volumes, the extra in GB, and a proposed alternative.

Hint

Base64 multiplies by 4 ÷ 3.

Hard

Hard 1: Rewrite or not (45 minutes)

A table of 3 billion rows, 150 bytes each, needs a new column with a default value. Compare adding a nullable column, filling it in batches, and a full rewrite. Estimate the time of each at 80 MB per second of spare I/O, and state the effect on readers who run old code.

Done when: three plans, three time estimates and a statement on compatibility.

Hint

Time = bytes ÷ throughput.

Hard 2: Choose formats for a platform (45 minutes)

A video platform has a public API, internal services, an event stream of 1.5 billion events a day and a warehouse. Choose a format for each and justify it with size, compatibility and tooling. Estimate the daily size of the event stream for 60-byte and 140-byte encodings.

Done when: four choices with reasons and two stream sizes.

Hint

Events × bytes per event.

Hard 3: The lost field (50 minutes)

Service A (version 2) writes a user record with a new field timezone. Service B (version 1) reads the record, changes the user's name and writes it back. Describe what happens to timezone if B decodes into its own objects. Give two ways to prevent the loss and a test that would catch it.

Done when: a step-by-step description of the loss, two fixes and a test case.

Hint

The old code never saw the new field in its model.