Boss: Architecture at scale
Pick the shape
A new studio with four developers is starting its backend. What does Martin Fowler's "monolith first" suggest?
- Start with one well-organised program, and split out services once the boundaries are clear
- Start with one microservice per feature
- 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.
- True
- False
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?
- MINOR
- MAJOR
- PATCH
Show the answer
MINOR
MINOR is for new functionality added "in a backward compatible manner".
Bug hunt
1async function onMsg(m) {2 await giveSeeds(3 m.body.playerId, 50);4}
The queue delivers at least once. What is missing?
- A check that skips a message ID already handled
- A longer function name
- 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?
- Update the database, then remove the cached copy
- Remove the cached copy, then update the database
- 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.
- True
- False
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?
- Stripe returns the saved result of the first request
- The player is charged twice
- 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
1Bucket size: 5 tokens2Refill: 1 token per second3The bucket is full.
A client sends 7 requests at once. How many get 429?
- 2
- 0
- 6
Show the answer
2
Five tokens let five through at once. The other two are refused until tokens drip back.