System Design — Instagram
7 min readSep 25, 2019
Product Requirements
- [Post] User can create a post (image + text (optional))
- [Post] User can comment on a post
- [Post] User can like a post
- [Feed] User can get follow feed ordered by time (landing page)
- [Feed] User can get profile feed of another user ordered by time
The above functionalities can be grouped into two: post and feed.
Follow feed is the default landing point, thus has to handle heavy traffic. It’s worth to put much engineer effort to it.
Non-product Requirements
- Performance: low latency, follow feed should be fast cause it’s the landing point
- Persistency: contents uploaded by user must not be lost
- Accuracy: order of post and number of likes user receives can be less strict.
Interface/API
- create_post(user_id, image, text, timestamp) -> success/failure
- assume every post has an image, and optional text
2. comment_post(user_id, post_id, comment, timestamp) -> success/failure
- assume you can comment on a post, but not on another comment