Design a photo-sharing social media platform where users can upload photos, follow other users, and view a personalized feed of posts from accounts they follow. Users expect fast uploads, instantly visible posts, and a smooth infinite-scroll experience with no duplicates or gaps.
Instagram-style platforms involve two fundamentally different data paths: the creator path (upload media, apply metadata, publish) and the viewer path (discover, scroll feed, interact). At Amazon, interviewers use this to assess whether you can design for large blob handling with reliable uploads, a low-latency high-scale feed, hybrid fanout strategies for celebrity accounts, and robust cursor-based pagination. Expect to abstract the follow graph and focus on client-visible performance rather than infrastructure minutiae.
Based on real interview experiences, these are the areas interviewers probe most deeply:
The core architectural decision is how you populate each user's feed. Interviewers want to see if you understand the fundamental tradeoff between fanout-on-write (pre-computing feeds) and fanout-on-read (aggregating on demand), and why a hybrid approach is necessary.
Hints to consider:
Photos and videos are large binary objects that should never flow through your application servers. Interviewers look for a clear separation of control plane and data plane.
Hints to consider:
Publishing a post triggers fan-out to potentially millions of feeds, media processing, cache warming, and notification delivery. All of this must happen without blocking the creator.
Hints to consider:
Feeds are overwhelmingly read-heavy. Interviewers expect a multi-layer caching strategy that serves most requests without hitting the primary database.
Hints to consider:
Start by confirming scope with your interviewer. Ask about the expected daily active user count, average follow count, and celebrity threshold where behavior changes. Clarify whether the feed is purely chronological or algorithmically ranked. Determine if group posts, stories, or reels are in scope. Confirm media size limits and whether video is required. Establish latency targets for feed loads versus uploads.
Sketch the major components: client applications (mobile, web), an API gateway, a post service for creating and retrieving posts, a feed service for generating and serving user timelines, a media service handling upload URLs and processing triggers, and a social graph service managing follow relationships. Show object storage (S3) for media with CDN delivery, a relational or NoSQL database for post metadata, Redis for cached feeds and hot data, and Kafka for event-driven fan-out and media processing pipelines. Draw the two main flows: creator uploads media directly to S3, posts metadata to the post service which publishes to Kafka, and fan-out workers populate follower feeds; readers hit the feed service which reads from Redis cache or reconstructs from storage.
Walk through the hybrid fan-out approach in detail. When a regular user (under 10k followers) creates a post, publish an event to Kafka partitioned by creator ID. Fan-out workers consume the event, look up the creator's follower list, and write the post reference (post_id, timestamp) into each follower's feed in Redis (ZADD to a sorted set) and the persistent feed table. For celebrity accounts (over 10k followers), skip the fan-out write. Instead, when a user loads their feed, the feed service reads their pre-materialized feed from Redis, then queries a separate celebrity-posts index for recent posts from any celebrities they follow, merges and sorts the combined results, and returns the page. Discuss cursor-based pagination: each response includes a cursor encoding the last item's (timestamp, post_id), and the next request uses that cursor to fetch the subsequent page deterministically.
Cover media processing by explaining that S3 upload completion events trigger a Kafka message consumed by transcoding workers that generate thumbnails and optimized formats, then update post metadata with media URLs. Discuss reliability through retry logic with exponential backoff for fan-out failures and dead-letter queues for persistent failures. Address monitoring: track fan-out lag, cache hit rates, feed load latency percentiles, and upload success rates. Discuss cache invalidation: when a user unfollows someone, remove that creator's posts from the user's cached feed. Touch on abuse prevention with rate limiting on uploads and posts per user.
Deepen your understanding of the patterns used in this problem: