Design a URL Shortener, stage 8 of 9: change it
New links show as "not found" in a new region
Replication lag is normally a few hundred milliseconds. The symptom lasts an hour.
System so far· 8 parts
Select a component to see what it is responsible for and which state it owns.
- 1Clickers → CDN edge: GET /aZ3kQ9x
- 2CDN edge → Redirect service: Cache miss
- 3Redirect service → Postgres: Look up code
- 4Customer dashboard → Links API: Create, edit, disable
- 5Links API → Postgres: Insert with unique code
- 6Redirect service → Click stream: Click event (fire and forget)
- 7Click aggregator → Click stream: Read click batches
- 8Click aggregator → Postgres: Upsert daily aggregates
- Request / response
- Asynchronous
What you need to know
0 of 2 checks done
A read replica copies every change from the primary database, usually within milliseconds, but never instantly. That delay is replication lag. A link created on the primary may be missing from a replica for a moment. See Replication.
A negative cache stores "not found" answers, so repeated requests for codes that don't exist (from scanners guessing codes, for example) don't hit the database.
Think first
A customer creates a link in the US. 200 ms later someone in Sydney clicks it. The Sydney replica doesn't have it yet, so the service answers 404, and the CDN caches that 404 for an hour, like any redirect. What does everyone else in Sydney see?Check
The Sydney replica doesn't have codeaZ3kQ9x. What does that tell you?