A photo feed has one question at its heart: when someone opens the app, how do you show them the latest posts from everyone they follow, fast? There are two broad answers, and each one breaks somewhere. The interesting part of this lab is finding where, and then combining them.
You'll design a photo-sharing app modelled on Instagram, from an empty page.
The brief
People post photos with a caption. They follow other people. When they open the app, they see a feed of recent posts from the accounts they follow, newest or best first, and they scroll. They like posts.
Most users follow a few hundred accounts and have a few hundred followers. A small number of accounts (celebrities, football clubs, brands) have tens or hundreds of millions of followers. That imbalance turns out to be the hardest part of the design.
In scope:
- Posting a photo with a caption.
- Following and unfollowing.
- The home feed: posts from accounts you follow.
- Likes and like counts.
Out of scope: stories, reels and video, direct messages, comments, search and explore, the ranking model itself (we'll treat ranking as "a function that scores a post"), and ads.
Requirements
Functional
- A user can upload a photo with a caption.
- A user can follow and unfollow other users.
- A user sees a home feed of posts from accounts they follow, paginated as they scroll.
- A user can like a post and see its like count.
Non-functional
- Feed loads fast: p99 under 200 ms for the first page of the feed, excluding image download.
- Images load fast worldwide.
- Highly available reads. If posting is briefly down, that's bad. If the feed is down, the app is dead.
- Eventual consistency is fine for the feed. A new post can take a few seconds to appear for followers. A celebrity's post can take a bit longer.
- Posts are durable. An uploaded photo is never lost.