Boss: Architecture at scale

Play this quiz

Pick the shape

A new studio with four developers is starting its backend. What does Martin Fowler's "monolith first" suggest?

  1. Start with one well-organised program, and split out services once the boundaries are clear
  2. Start with one microservice per feature
  3. Skip the backend
Show the answer

Start with one well-organised program, and split out services once the boundaries are clear

Fowler found that almost all successful microservice systems started as a monolith that got too big and was broken up.

Quick check

Removing a field from an API response is a breaking change.

Show the answer

True

Every app that reads the field fails. Under SemVer it raises the MAJOR number.

Quick check

The API adds a new optional feature that old apps can ignore. Under SemVer, which number goes up?

  1. MINOR
  2. MAJOR
  3. PATCH
Show the answer

MINOR

MINOR is for new functionality added "in a backward compatible manner".

Bug hunt

rewards-worker.js
async function onMsg(m) {  await giveSeeds(    m.body.playerId, 50);}

The queue delivers at least once. What is missing?

  1. A check that skips a message ID already handled
  2. A longer function name
  3. Nothing: queues never repeat
Show the answer

A check that skips a message ID already handled

At-least-once delivery means a rare repeat. Recording handled IDs makes a repeat harmless.

Quick check

With cache-aside, a garden is renamed. In which order should the server act?

  1. Update the database, then remove the cached copy
  2. Remove the cached copy, then update the database
  3. Only update the cache
Show the answer

Update the database, then remove the cached copy

The other order leaves a gap where a read stores the old name in the cache again.

Quick check

A read replica accepts writes.

Show the answer

False

Read replicas are read-only. Every write goes to the primary.

Quick check

An app retries a Stripe payment with the same Idempotency-Key. What happens?

  1. Stripe returns the saved result of the first request
  2. The player is charged twice
  3. Stripe deletes the payment
Show the answer

Stripe returns the saved result of the first request

Retries with the same key return the saved response, so the payment happens once.

Read the numbers

Limit
Bucket size: 5 tokensRefill: 1 token per secondThe bucket is full.

A client sends 7 requests at once. How many get 429?

  1. 2
  2. 0
  3. 6
Show the answer

2

Five tokens let five through at once. The other two are refused until tokens drip back.