CSE Roadmap

Common tier · about 4 hours · 7 parts

Part 7 of 7 · 3 min read

Exercises

Easy

Easy 1: Source and copies (20 minutes)

For an online shop, list the system of record and at least three derived systems for product data. State for each how fresh it must be.

Done when: a table with four rows and a freshness note each.

Hint

The database is the system of record. Cache, search and warehouse are copies.

Easy 2: Spot the race (20 minutes)

Two clients set a user's name to "Ann" and "Anna". The database sees Ann then Anna. The index sees Anna then Ann. What are the final values? Does anything report an error?

Done when: two final values and the answer to the error question.

Hint

The two systems end with different values, and neither reports anything.

Easy 3: Compact it (20 minutes)

A log has (k1,a), (k2,b), (k1,c), (k3,d), (k2,empty), (k1,e). Show the log after compaction.

Done when: the list of remaining records.

Hint

Keep the latest record for each key. An empty value is a delete.

Medium

Medium 1: Bootstrap an index (30 minutes)

A new search index is needed for a table with 50 million rows. The change stream keeps 7 days only. Describe the steps to build the index without missing or double-applying changes, including how the snapshot and the log position fit together.

Done when: a numbered plan of at least five steps with the position rule.

Hint

The snapshot's log position is where the change stream must start.

Medium 2: Lag budget (30 minutes)

A CDC pipeline has these delays: log read 20 ms, broker 30 ms, consumer 100 ms, index refresh 1 second. What is the usual delay? A consumer outage of 10 minutes happens while the database gets 200 changes per second and the consumer can apply 1,000 per second. How long to catch up?

Done when: a delay sum and a catch-up time with the arithmetic.

Hint

The backlog is 200 x 600 = 120,000 changes. Net drain is 1,000 - 200 = 800 per second.

Medium 3: Cache with versions (30 minutes)

Events arrive for key K in the order offsets 12, 14, 13, 14. Values are 5, 8, 7, 8. Show the cache content after each event with and without a version check.

Done when: two columns of cache values and the final value of each.

Hint

With versions, the late offset 13 is ignored because 14 is already stored.

Hard

Hard 1: Replace dual writes (45 minutes)

A service writes orders to PostgreSQL, updates Elasticsearch, clears a Redis cache and sends a message to billing. Redesign it with one write path. Show the flow, what happens with a crash at each step and how each consumer stays idempotent.

Done when: a diagram, a crash table with at least four cases and an idempotency rule per consumer.

Hint

Only the order write goes to the database. Everything else reads the change stream.

Hard 2: Rebuild after a bug (45 minutes)

An indexer bug mangled prices for three days. The change topic is compacted and the source database is intact. Plan the repair so search stays available. Include when to switch and how to check the new index before the switch.

Done when: a plan with a parallel build, a check and a switch and rollback step.

Hint

Build the new index next to the old one and switch an alias when it matches.

Hard 3: Triggers or log (50 minutes)

A team proposes database triggers to fill a changelog table. Another proposes reading the replication log. Compare them on load, ordering, schema changes, failure and operations. Choose one for a table with 3,000 writes per second and defend it.

Done when: a comparison table on five points and a reasoned choice.

Hint

Triggers add work to every write, and the log reader runs outside the write path.