System Design
Image Hosting
Design an image hosting and delivery service like Imgur or Instagram.
Functional requirements
- Users can upload an image (JPEG, PNG, GIF, or WebP, up to 20 MB) and get back a permanent public URL for it (e.g., img.host/a8Kd2Qx).
- Each image is served in several sizes, at least a thumbnail, a feed-sized medium variant, and the full-resolution original, each with its own stable URL.
- Viewers anywhere can load any variant through its URL, whether embedded in a web page, opened directly, or fetched by a mobile app.
- Uploaders can list their own images with basic metadata (dimensions, byte size, upload time) and delete any of them; a deleted image stops resolving within a bounded time.
- Uploading bytes identical to an image already stored (e.g., the same meme reposted by thousands of accounts) reuses the existing copy rather than storing it again.
Non-functional requirements
- Delivery is the critical path: p99 latency to first byte under 50ms for a variant served from the edge, and under 400ms on a miss that goes back to origin storage.
- The upload call returns a usable URL within 2s at p99 for a 5 MB file; a variant that is not ready yet must still resolve to something usable, never a 404.
- Availability over consistency for reads: a new upload may take seconds to appear worldwide and a deleted one may linger at edges for up to a minute, but a URL must never serve a different image than before.
- Once the upload call returns a URL, the original bytes must never be lost (99.999999999% durability across at least three zones); derived variants are disposable and regenerable from the original.
- Uploads are validated (real image bytes, size and dimension limits, location EXIF stripped) and URLs are not enumerable, so private images cannot be found by guessing.
Scaling & constraints
- 10M image uploads per day (~115/s average, ~600/s at the daily peak); the average original is 2 MB, the maximum 20 MB.
- Read:write ratio is roughly 150:1: ~1.5B image views per day (~17K/s average, 3x at peak), about 85% of them thumbnails or medium variants and 15% full resolution.
- Metadata per image is ~1 KB; originals are retained indefinitely, adding ~20 TB of new originals per day, and upload volume grows ~30% per year.
- Roughly 1 in 12 uploads is byte-identical to an image already stored, and a viral meme can be re-uploaded 50,000 times in a single day.
- Views are highly skewed: the top 1% of images receive ~80% of views, and a new image gets most of its lifetime views in its first 24 hours.
- Resizing a 2 MB original into the full variant set takes ~300-800ms of CPU on one core; a blob storage put is ~50-100ms at p50 and an in-region origin read is ~30ms at p50.
Out of scope
- User accounts, authentication, and billing.
- Content moderation, NSFW detection, and copyright matching.
- Albums, comments, likes, and other social features.
- On-the-fly transformations requested via URL parameters (arbitrary crops, filters).
Sign in to save your progress
AI design evaluation
Get a score, what your board does well, what to fix first, and what an interviewer would ask next.
Sign in to get AI feedback on your design.