Design an image hosting service (like Imgur)
medium 50 minUpload a picture, get a link at once, and let the whole world look at it.
Explain your choices
Answer first. Then compare your reasoning.
12 questions 0 got it 0 to review12 not marked
Summary
Trade-offs and push-back
Decisions
| Decision | Choice | Because |
|---|---|---|
| Serve original or copy | Copy only | Privacy, safety, size |
| Sizes ahead or on demand | Three ahead, others on demand | Fast common case, small store |
| Answer when | Original safe | The user wants the link |
| Browser life | One hour | Takedown |
| Duplicates | Share blobs, not records | Owners stay separate |
| Shard key | Image ID | Almost every read has it |
| Counts | Edge logs, minutes late | Origin never sees 95% of views |
| Checks | Before public | Caches remember |
| Regions | One writes, CDN everywhere, copy for reads | Writes are few |
When they push back
| They say | Answer with |
|---|---|
| "Why not files in PostgreSQL?" | "13.8 PB of bytes nobody queries. Backups and replicas would carry them too. Records stay there." |
| "Users want it instantly." | "They get the link instantly. For 4 to 8 seconds it shows a placeholder. For trusted accounts I could publish first, and I would say the risk." |
| "Resize everything at the edge." | "Good when most images are never opened. At 500 views an upload, three stored sizes are cheaper than repeating the work. I would compare prices." |
| "A year of caching is faster." | "Yes. A takedown could not reach browsers for a year. I trade a few repeat downloads for that." |
| "You will never be as big." | "Then version 3 and a CDN plan. Nothing in the API changes." |