AlgoViz

Design an image hosting service (like Imgur)

medium 50 min

Upload 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

DecisionChoiceBecause
Serve original or copyCopy onlyPrivacy, safety, size
Sizes ahead or on demandThree ahead, others on demandFast common case, small store
Answer whenOriginal safeThe user wants the link
Browser lifeOne hourTakedown
DuplicatesShare blobs, not recordsOwners stay separate
Shard keyImage IDAlmost every read has it
CountsEdge logs, minutes lateOrigin never sees 95% of views
ChecksBefore publicCaches remember
RegionsOne writes, CDN everywhere, copy for readsWrites are few

When they push back

They sayAnswer 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."