Designing Instagram in a mobile interview is different from designing it as a backend system. The interviewer wants to see if you understand the client realities: cellular bandwidth costs money, scrolling has to feel instant, photos uploaded over flaky LTE need to survive app suspension, and the feed has to keep working when the user is on the subway.
Functional requirements
- Browse a personalized feed of photos and videos
- Watch Stories (24-hour ephemeral content)
- Upload photos with filters and edits
- Like, comment, and DM
- Search by hashtag, user, location
Non-functional
- Feed first paint under 500ms; image load under 1s on 4G
- Smooth 60fps scroll
- Upload survives app backgrounding and network drops
- Reasonable cellular data usage
Feed pipeline
Server returns a paginated feed with ~10 items per page. Each item has a CDN URL for the photo at multiple resolutions (e.g., 320, 640, 1080 wide).
Client uses a feed adapter: as the user scrolls, prefetch the next page when they reach the 60% mark. Image loading is deferred until cells are ~2 screens away, at which point we fetch the appropriate resolution for the device.
Photo upload pipeline
The hardest path. The user picks a photo, applies filters, taps post, then immediately scrolls away or backgrounds the app. We need to:
- Apply filters in a GPU-accelerated pipeline (Metal on iOS, OpenGL ES on Android)
- Re-encode at upload resolution (1080 wide, JPEG q85)
- Hand the file to a background uploader (URLSession background config on iOS, WorkManager on Android)
- The uploader resumes if the app is killed; reports progress when foreground
- Server returns post ID; client updates feed with optimistic insert
Stories
Stories are videos and photos with auto-advance. Prefetch the next 2 stories aggressively. When the user taps right, the next is already decoded and ready. Stories are paged from a per-user manifest that lists all available stories with TTLs.
Caching
Three-tier cache: in-memory NSCache/Glide-style memory cache (~50MB), on-disk LRU (~500MB), and the network. Eviction is size-based, not just LRU — we keep small thumbnails longer.
Battery and data
- Pause auto-play of videos in feed when on cellular if user has data-saver enabled
- Don’t prefetch in background
- Compress images on upload using HEIF when both server and device support it
Frequently Asked Questions
How do you make scroll feel instant?
Recycle cells aggressively, decode images off the main thread, hold a small placeholder in memory, and never block UI on network IO. Pre-rendered cell heights (no auto-layout for the photo aspect) help too.
What if the user uploads a 50MB photo on bad network?
Resumable upload with chunks (e.g., 1MB chunks via tus protocol or signed multipart S3). Background URLSession can resume across app launches.
How do you rank the feed?
Server-side ranking model considers recency, relationship strength, engagement signals, and content type. Client receives a pre-ranked list; in some implementations the client reorders the top-K based on local signals (e.g., last viewed item).