Skip to main content

Instagram

What is Instagram​

img_546.png img_547.png

Requirements of Instagram’s Design​

img_548.png

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.

img_549.png img_550.png img_551.png img_552.png img_553.png img_554.png img_555.png img_556.png

Design of Instagram​

img_557.png img_558.png img_559.png img_560.png img_561.png img_562.png img_563.png


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.


img_564.png img_565.png

Detailed Design of Instagram​

img_566.png img_567.png img_568.png img_569.png img_570.png img_571.png img_572.png img_573.png img_574.png


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.


img_575.png


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.


img_576.png img_577.png img_578.png


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.


img_579.png

img_580.png img_581.png img_582.png