How would you design Instagram?
Instagram processes over 100 million photos per day. Each photo gets uploaded, stored, processed into multiple resolutions, served through a CDN, and disp...
31 Mar 2024

Instagram processes over 100 million photos per day. Each photo gets uploaded, stored, processed into multiple resolutions, served through a CDN, and displayed in feeds ranked by a recommendation algorithm — all in under a second from the user's perspective.
The interesting system design challenge isn't "how do you upload a photo." It's "how do you do that 100 million times a day while keeping the feed personalized and the app fast."
Non-Technical Requirements
- Scalability — billions of photos in storage, millions of active users, hundreds of millions of feed requests per day. Horizontal scaling is mandatory.
- Reliability — once a photo is uploaded, it must never be lost. Users treat Instagram as their photo archive. Data durability is critical.
- Availability — 24/7 global service. Downtime during peak hours (evening, weekends) is especially costly because that's when users are most active.
- Content Moderation — detect and remove nudity, violence, spam, and hate speech. This must happen at upload time (or close to it) to prevent harmful content from spreading.
- Privacy — private accounts, blocked users, restricted content. Permissions must be enforced consistently across feeds, search, and direct messages.
Technical Requirements
- Media Storage and Delivery — store photos and videos in multiple resolutions. Serve them from edge servers close to users. Support various formats and device screen sizes.
- Real-Time Processing — process likes, comments, follows, and story views in real-time. Update counters, notifications, and activity feeds instantly.
- High Throughput — millions of writes per second (likes, comments, story views). The system must handle this without degradation.
- Content Discovery — Explore page, hashtag search, account recommendations. These require search indexes, ranking models, and real-time trend detection.
- API Support — public APIs for third-party integrations, business tools, and content scheduling platforms.
Low-Level Design
Media Storage. Photos and videos go to distributed object storage (S3 or equivalent). Each upload gets processed into multiple sizes: thumbnail, feed-size, full-resolution. Videos get transcoded into multiple bitrates for adaptive streaming.
Database Layer. PostgreSQL for user data, account settings, and relationships. Cassandra for feed data and activity logs (high write throughput, partition by user ID). Redis for caching hot data — user sessions, popular posts, follower counts.
CDN. Media assets are served through a global CDN (Cloudflare, Akamai, or a custom solution). Cache hit rates above 95% for popular content. This is what makes the app feel fast regardless of the user's location.
Stream Processing. Kafka ingests events (likes, comments, follows, views). Stream processors compute real-time metrics, update counters, trigger notifications, and feed activity to the recommendation engine.
Content Moderation. ML models scan uploads at ingestion time. Image recognition detects policy violations. Confidence scores determine whether content is auto-blocked, flagged for human review, or approved.
High-Level Design
- Client Applications — native iOS and Android apps plus a web interface. Each implements media upload, feed rendering, stories, messaging, and real-time updates.
- Backend Services — microservices for auth, media upload, feed generation, messaging, notifications, search, and content moderation. Each service scales independently.
- API Gateway — handles authentication, rate limiting, request routing, and API versioning.
- Search and Discovery — Elasticsearch for hashtag search, account search, and location-based content. ML-based ranking for the Explore page.
- Infrastructure — cloud-based (AWS/GCP) with auto-scaling, load balancing, and multi-region deployment for global availability.
The Trade-Offs
Feed generation: push vs. pull. Instagram uses a hybrid approach. For users with a small number of followers, new posts are pushed into followers' feeds at write time (fanout on write). For celebrity accounts with millions of followers, feeds are assembled at read time (fanout on read). Push gives fast reads but expensive writes. Pull gives cheap writes but slower reads.
Media processing: synchronous vs. asynchronous. Uploading a photo and waiting for all resolutions to generate would be slow. Instead, the upload returns immediately, and processing happens asynchronously. The feed shows a placeholder until the processed versions are ready. Fast UX, but briefly inconsistent.
Consistency vs. availability. Like counts don't need to be perfectly accurate in real-time. If a post shows 1,234 likes when the true count is 1,237, nobody notices. Instagram trades strong consistency for availability and performance on non-critical counters.
Moderation speed vs. accuracy. Automated moderation catches most violations quickly. But false positives (blocking legitimate content) hurt creators. False negatives (missing harmful content) hurt users. Instagram balances this with confidence thresholds — high-confidence violations are auto-removed, borderline cases go to human review.
The architecture scales because it treats different data types differently. User profiles need strong consistency. Like counters need high throughput. Media needs durable storage and fast delivery. Each gets the right infrastructure for its access pattern.
Keep reading
- The Capacity Estimation Numbers Every Engineer Should Carry Into a System Design
- Notes From My First Cohort: System Design Is Trade-offs, Not Answers
- Write HLDs and ADRs in HTML or React, Not Markdown
- CRDTs: Conflict-Free Merging in Distributed Systems
- Race Conditions: What They Are and How to Handle Them
- SLO, SLA, SLI: What They Actually Mean and How to Use Them