~learn.
0:00 / 1:28
W01 · Data at scale

The primary database dies. Every short link still works.

transcript

Your URL shortener's primary database just died. Every short link still works. That was the plan all along.

It starts in the requirements. Redirects are ten times the traffic. So redirects promise 99 point 99 percent. They're the critical path. Creating a link promises 99 point 9. One nine less. So they're two separate services. Scale and protect the hot path on its own.

A click hits the redirect service. It reads Redis first. On a miss, it reads a replica. Briefly stale is fine for a redirect. The primary only takes writes. So when it dies, the clicks never notice.

Now walk the failures. All of Redis goes down? Redirects fall back to the database. Slower, not broken. The primary goes down? No new links, until the sync replica is promoted. Redirects carry on. The CDN goes down? More load on your servers. Fail over through DNS to a backup CDN.

See it now? Creation needs the primary. Redirects never do. That's exactly why creation promised one nine less. The design and the promise match.

Don't give a whole system one number. Give each path its own promise. Then design so a failure only breaks the cheaper one.

Full breakdown in the lecture.