What is Instagram

Requirements of Instagram’s Design

Details
To implement a time-based expiration feature for the content on Instagram, we would need to add or modify the following requirements:
- Content Expiration: Introduce a new functionality that allows users to set a time limit for their posts. After the set time, the posts will automatically be removed from Instagram.
- View Expiration Status: Users should have the ability to see how much time is left before a post expires, possibly through a countdown timer on the post itself.
- Notification of Expiration: Users should be notified before their content is about to expire, offering them an opportunity to extend the time if desired. These changes would ensure that the new time-based expiration feature works seamlessly and is user-friendly.

Design of Instagram

Where should we store the photos and videos?
Details
We’ll store the photos and videos in a blob store (like S3) and save the path of the photo or video in the table as it is efficient to save larger data in a distributed storage.

Detailed Design of Instagram

What are the shortcomings of the pull approach?
Details
Instagram is a read-heavy system. Many people don’t post any photos and instead just view others’ posts. So, the calls we make to fetch the recent posts from every follower will usually return nothing. Hence, we should keep in mind that it is not a write-heavy system and should develop a possible solution to cater to it.

What are the shortcomings of the push approach?
Details
Consider an account that belongs to a celebrity, like Cristiano Ronaldo, who has over 400 million followers. So if he posts a photo or a video, we will push the links of the photo/video to 400 million+ users, which is inefficient.

How can we count millions of interactions (like or view) on a celebrity post?
Details
We can use sharded counters to count the number of multiple interactions for a particular user. Each counter has a number of shards distributed across various edge servers to reduce the load on the application server and latency. Users nearest to the edge server get the updated count frequently on a specific post compared to those in distant regions.

