Scope
Functional
- Upload a photo with caption; view a post; like and comment.
- Profile grid; home feed (reuse Case Study C6 of the book's feed design).
- Stories that disappear after 24 hours.
Non-functional
- Upload acknowledged in < 2 s; photo visible to followers within ~10 s.
- Image load p99 < 300 ms worldwide; uploads never lost.
- 500M DAU.
Size
- 50M photo posts/day → ~600 uploads/s (peak ~2k).
- Original 3 MB + variants (1080, 640, 320, thumbnail; WebP/AVIF) ~1 MB → 200 TB/day.
- Views: 500M × 100 images/day = 50B/day ≈ 600k images/s; at ~100 KB each → 60 GB/s. CDN mandatory.
- Likes: 4B/day ≈ 46k/s, very spiky on viral posts.
APIs
POST /v1/media/uploads → {upload_id, presigned_url}
POST /v1/posts {upload_id, caption} → {post_id, status: PROCESSING}
GET /v1/posts/{id}
POST /v1/posts/{id}/likes (idempotent per user)
GET /v1/posts/{id}/comments?cursor=The architecture
- The client uploads to the raw bucket via a pre-signed URL (resumable for poor networks).
- The post is created in
PROCESSINGstate. - Processors validate (type, size, malware, safety ML), generate variants and store them under content-addressed keys.
- The post flips to
PUBLISHED; an event triggers feed fan-out. - Clients request the variant that fits their screen from the CDN.
The 30-second summary
Say it in the interview
"Uploads go straight to object storage through pre-signed URLs; an async pipeline validates and produces immutable variants that are served through a CDN with an origin shield. Post metadata is sharded SQL; publishing emits an event that drives the feed. Likes are stored per user for idempotency, with counts in sharded counters to avoid hot rows. Stories use TTLs and lifecycle rules."
Follow-up questions the interviewer may ask
- How do you show a photo before processing finishes?
- How do you stop duplicate uploads from wasting storage?
- How do you serve the right image size to each device?
- How do you handle deletions and privacy?
Model answers to each of these are in the book.