Design a hosting service for static websites, like a simple version of Netlify or GitHub Pages. Customers upload a folder of HTML, CSS, JavaScript and images, and the site goes live on a subdomain or their own custom domain. The platform hosts 2 million sites. Most get a handful of visits a day, but a few hundred are popular, and together visitors make about 5,000 requests per second at peak. Every deploy must replace the whole site at once, so visitors never see a mix of old and new files.
Functional requirements
Upload a new version of a site (a deploy) through an API or CLI
Serve each site on a default subdomain and an optional custom domain
Serve HTTPS for every domain
Roll back to a previous deploy in one step
Non-functional requirements
Pages load in under 250 ms at p95 for visitors worldwide
A deploy switches over atomically: all new files or all old files
Uploaded files are never lost
Constraints and scale
2 million hosted sites, 50 MB per site on average
5,000 visitor requests per second at peak
About 20,000 deploys per day
You will practise
Serve static content from object storage behind a CDN
Map custom domains to sites with DNS and TLS certificates
Make deploys atomic by publishing immutable versions and switching a pointer
Show 2 hints
Static files never change once uploaded. What does that let a CDN do?
Instead of overwriting files, store each deploy under its own prefix and switch which one is live.