Modern System Design

System Design of Instagram

2 min read

 

Overview:

 

In this article, we are going to drill down how to build the Instagram. Instagram is photo and video sharing social networking service.

We are going to build the simpler version of Instagram for this design problem, where a user ca share photos and follow other users, The ‘Feed’ for each user will consist of top photos and follow other users. The ‘feed’ for each user will consist of top photos of all the people the user follows.

 

 

Requirements:

 

 

Functional:

 

  1. Upload images from a client
  2. User follow other users
  3. Generate a feed of Images
  4. User can search based on photo/Video titles

 

 

 

Non Functional:

 

  1. Highly available
  2. High reliable – any photo that was upload should never be lost. 
  3. Low latency
  4. Low in consistency should be fine that means users not able to see the newly uploaded photo should be fine.

 

 

 

Capacity Estimate:

 

Lets assume we have 100M total users and 1 M daily active users.

Lets say 2M new photos uploaded everyday and avg size of photos are 200KB. That means 2M * 200KB= 400GB storage required for 1 day.

 

Total space required for 1 year will be 400 GB * 365 days =  142 TB

 

 

 

 

High Level Design of Instagram:

 

 

  1. User will be using any client mobile/desktop application to connect to backend server via rest API.
  2. Request first will go to load balancer and that will distribute the traffic between backend servers to make service more available. 
  3. Then the request will go to image service that is responsible for provide the APIs to upload and get the metadata. This Image service will take the request and upload the image to S3 Bucket that is our Object store and it will also upload the metadata to AWS Dynamo DB. 
  4. AWS S3 is scalable and cheap object storage to store the images uploaded by users. 
  5. We should be using AWS Cloudfront that is content delivery network (CDN) to get the high performance and faster rendering. 
  6. Image’s metadata will be stored in AWS Dynamo DB such as Title, user details, locations etc. 
  7. While performing these steps Image server will publish the notification using AWS Simple Notification service to monitor, log events. 
  8. AWS Simple Queue server will upload event SNS and the feed generation service will listen to this SQS for processing the events. 
  9. Feed generation service will upload the events using SQS and update the user feed. I will store the user feed details on Feed Dynamo DB. 
  10. Redis cache will provide us low latency. Request will come to fetch user feed, it will first check in the redis cache and server the request else, fetch the details from feed dynamo db.

 

 

 

Thank you for reading. We hope this gives you a good understanding. Explore our Technology News blogs for more news related to the Technology front. AdvanceDataScience.Com has the latest in what matters in technology daily.

Tagged , , , , , , , , , , , , , , , , , , , ,