CSE Roadmap

Common tier · about 4 hours · 7 parts

Part 7 of 7 · 3 min read

Exercises

Easy

Easy 1: Command or event (20 minutes)

Label each as a command or event: "Charge card 4411"; "Card 4411 was charged"; "Ship order 77"; "Order 77 shipped"; "Delete user 9".

Done when: five labels and the event wording for each command.

Hint

Imperative sentences are commands. Past tense statements are events.

Easy 2: Replay an account (20 minutes)

An account log: opened 0; deposit 200; withdraw 50; deposit 30; withdraw 80. Find the balance after each event and at the end.

Done when: five balances.

Hint

Keep a running total. Deposits add and withdrawals subtract.

Easy 3: Read model names (20 minutes)

For a bookshop with an event "book sold", name three read models (what each answers) that could be built from it.

Done when: three views, each with the question it answers.

Hint

Think "sales per day", "stock left", "best sellers".

Medium

Medium 1: Orchestrate or choreograph (30 minutes)

A new user signs up. Create an account, send a welcome email, grant 100 bonus points and add them to a mailing list. Write the process once as orchestration and once as choreography, and list what is easier and harder in each.

Done when: two sketches and a four-line comparison.

Hint

In orchestration, one service calls the three. In choreography, they all hear the same event.

Medium 2: Snapshots (30 minutes)

An account has 1,000,000 events and a snapshot every 10,000 events. Replaying 1 event takes 20 microseconds. How long is a full replay? How long when the last snapshot is at the worst place (just before the next one)?

Done when: two times with arithmetic, and a statement about the saving.

Hint

1,000,000 times 20 microseconds is 20 seconds. The worst case replays 9,999 events.

Medium 3: Reading your own write (30 minutes)

A user posts a review, and a read model shows reviews per product with a delay of about 2 seconds. Describe three ways to avoid the user seeing their review missing, and the cost of each.

Done when: three options in a table with cost and weakness.

Hint

Reading from the write side, showing locally, or waiting briefly are the usual three.

Hard

Hard 1: Event design (45 minutes)

Design the events for a ticket booking system: browse, hold, pay, confirm, cancel, refund. Give names, fields and the order. State which are commands, and where a check must happen before the event is created.

Done when: a table of events with fields, plus a statement of the two places where checks happen.

Hint

Holding a seat must be checked against availability before the hold event exists.

Hard 2: New feature from the log (45 minutes)

A shop's order events have been stored for two years. Management wants a new report, "customers who bought X also bought Y". Describe how to build it as a new read model without touching the existing system, how to deal with the backfill and live events, and how to check it.

Done when: a plan of at least six steps with the backfill method and a checking method.

Hint

Start a new consumer at offset 0 of the order log, and let it catch up to live events.

Hard 3: Delete under a law (50 minutes)

A user demands deletion of all personal data. The system uses event sourcing, three read models and nightly backups. Propose a design that keeps events useful but meets the demand. List what is removed from the log, the read models and the backups, and what you cannot fully guarantee.

Done when: a design with three places, a timeline and an honest statement of the limit.

Hint

Store personal data in a separate store and refer to it by id inside events.