Photo Sharing Cheat Sheet
Key concepts, trade-offs, and quick-reference notes for your interview prep.
Photo Resolution Variants
#1💡 We generate the thumbnail first (not all 4 in parallel from the start) because the grid view needs the 150px variant within 1 second. The other 3 sizes process in parallel after the thumbnail is ready.
Daily Storage Growth
#2Instagram 64-bit ID
#3💡 The timestamp occupies the high-order bits, so IDs are time-sortable by default. ORDER BY photo_id = ORDER BY created_at. We skip the secondary index on created_at entirely.
Celebrity Fanout Threshold
#4Feed Cache Sizing
#5💡 We store photo IDs only (not photo objects) in the feed cache. Hydrate at read time via a batch MGET from the photo metadata cache. One extra round-trip (~2ms) saves 500x memory.
CDN Cache Hit Ratio
#6Upload and Read QPS
#7💡 The 50:1 ratio means optimizing the read path (CDN, cache) has 50x more impact than optimizing writes. We design the CDN layer first, upload pipeline second.
Like Counter Strategy
#8Image Processing Target
#9💡 The user sees a placeholder until the thumbnail is ready. Once the 150px variant exists (under 1 second), the grid view populates. Full-size loads lazily when the user taps.