CDN & Edge
Serve bytes close to users so your origin never sees them.
A CDN caches static and media content at the edge. Your origin only sees the misses — until the CDN is purged or a new object goes viral and every edge fetches it at once.
Concepts
- Edge hit rate
- At 95% the origin sees 1 request in 20; a purge sends it everything.
- Origin shielding
- Protect the origin from the thundering herd of edge misses.
- Static vs dynamic
- CDNs absorb media and assets; the dynamic API is what you must scale yourself.
Lab
Problems
- YouTube: Viral Video — Medium — A video goes viral: 4× traffic and an exploding transcoding backlog.
- Ticketmaster: Stadium Tour On-Sale — Hard — The biggest tour of the year goes on sale at T+20s: six times the fans, a scalper botnet, and every seat of the show in one database partition. Be ready before the doors open.
- Dropbox: Monday 9 a.m. — Hard — Monday morning: sync traffic ×2.5, uploads ×2.5 — and at T+90s the metadata primary dies. Every request counts, so the system must be ready before nine.
- Netflix: Season Premiere at Midnight — Hard — Midnight premiere: five times the viewers, every edge cold for the new episode, an origin that cannot scale — and then recommendations slow to a crawl.
- Instagram: The Celebrity Post — Hard — A celebrity posts a photo: one image takes 70% of image traffic, and the post’s reads and likes all land on one Cassandra partition — likes cannot be cached.
- LeetCode: Weekly Contest Start — Hard — The contest starts: eight times the coders for two minutes, every one opening the same four problems and submitting — and each submission holds a serverless execution for its whole judge run.
- One Viral Video — Easy — A clip goes viral: traffic doubles and 70% of it asks for one object, which lives on one Varnish node. More Varnish nodes barely move the ceiling.
- Above the CDN’s Limit — Easy — A launch pushes static traffic 60% over your CDN contract. The CDN cannot be scaled, and every extra miss lands on an S3 bucket already near its limit.
- Evacuate the Region — Easy — us-east-1 goes dark. A full standby stack runs in us-west-2 — but every user’s app is pointed at us-east.
- Credential-Stuffing Botnet — Easy — A botnet sends 1.6M login attempts per second at your load balancer. Real users drown — and nothing behind the uplink can drop the flood in time.
- Uploads Through the API — Easy — Every 200 MB video upload holds an API thread for 1.5 seconds. Upload traffic is about to multiply by 2.5 — and new instances take two minutes to boot.
- Cloudflare: The Regex That Took Down the Edge — Hard — A managed WAF rule with a catastrophic regex pins every edge CPU, and half a minute later a botnet notices. You have seconds — and the WAF cannot simply be switched off for everyone.
- AWS S3: The Day the Object Store Went Dark — Hard — The region’s object store goes down for fifteen minutes. Three different parts of your system depend on it — one of them is your status page — and nothing new can boot.
- Fastly: When the CDN Disappeared — Hard — Your only active CDN returns errors worldwide. A second CDN is under contract but cold, the origin can serve a fifth of the traffic, and every second counts.
- Pokémon GO: Fifty Times the Plan — Hard — Launch day brings eight times the worst case you planned for. Clients retry three times, one park has every spawn, the world database is write-bound and map tiles melt their API.
- Coinbase: The QR Code Commercial — Hard — A bouncing QR code during the big game: a hundred times the visitors for one minute, sign-ups calling a slow identity vendor, and existing customers checking prices at the same time.
- Healthcare.gov: Launch Day — Hard — Six times the expected visitors on day one: plan browsing that was never cached, a synchronous identity vendor, a data hub that waits on three agencies, and an autoscaling tier with a fixed database.
- Shopify: The Celebrity Flash Sale — Hard — A celebrity’s product drop brings eighty times their usual traffic onto the shared platform. No other merchant may notice, no fan’s order may be lost — and the drop starts in one minute.
Codelays runs in your browser: turn on JavaScript to use it.