How would you design a service like Instagram? Estimate server and storage requirement for peak traffic.

  Google
  Stripe
Add Your Answer
Answers (1)

1. Understanding the product – ‘Instagram’

– A photo and video sharing site

– A photo and video searching site (by interest)

– Follow media posted by particular users/ groups/ #tags

– Anything else?

This is good. This is all the product does. Go ahead!

Tech design requirements

1. Latency – <1ms

2. Availability (no 500 errors) – 100%

3. Storage by user, by trend, by hashtag, by category (may require AI for category)

4. Search by user, by trend, by hashtag, by category (fast response – less than 1 second)

Peak time requirements

Server side –

1. First we need to understand what is peak and what does the traffic look like.

Lets say peak is holiday season where there is a lot of media being uploaded or shared (peak can also be during any other time that enables lot more traffic of uploading and searching, but for this case, is holiday season a good way to think about this?)

Yes, go ahead!

2. And do we focus on US or world wide?

US

3. Great. In US of the the 320MM populations, with 4MM each from 0 yrs to 80 yrs (with 80 yrs being the expected life expectancy), I estimate population from 16yr to 40 yrs to be very active on internet and that is about 25*4MM = 100MM population. Of this I expect about 80% of this population is going to be on instagram yr in US. That is 80MM. Now on a regular day, I believe per user posts about 5 posts per hour and searches about 5 times a day. That is 5*24=120 posts/day per user and 5 searches resulting in 20 posts per serach being rendered per day/user (20 is an assumption). Due the peak, I assume this will grow twice (we can see past trends) and peak is say start to halloween to start of new yr (so Oct 24 to Jan 7) and that is 8 days in October, 30 days in November, 31 days in December and 7 days in January = 75 days (peak season). In this season we would see 240 posts/day/user and 10 searches per day per user resulting in 200 posts. I expect the 80MM user base to be active and assume that we get 1% more users so about 81MM users. The peak traffic is

User posts = 81MM users * 200 posts/user/day * 50% users active = 8100MM posts/day = ~8 BB posts/day

User searches = 81MM users * 10 searches/user/day * 20 posts/search * 50% users active = ~8BB posts searched/day

This is the estimated daily traffic.

This translates is get and posts requests into the server per day.

A user post requires the following steps –

1. Open app -> get request (sent to server and server responds with a success 200). If 81MM * 50% activeusers access their app 10 times a day with 5 times requires a new connection to the server, then that is about 200MM get requests to the server per day

2. Upload a photo or media -> post request (server saves the media under the user account and sends a success 200). Lets say the posts are 50% photos and 50% media. Each poto is 1MB and each media(video) is 5MB. So the post paylod per day is about = 4Billion*1MB + 4Billion*5MB = 24Billion MB per day

3. Storage requires -> 24Billion MB of data needs to be stored in the db with right identity keys and categorization so these searched easily.

Latency maintained at <1ms

A user search requires the following steps

1. Open app -> get request (sent to server and server responds with a success 200). Assuming the same as above -> If 81MM * 50% activeusers access their app 10 times a day with 5 times requires a new connection to the server, then that is about 200MM get requests to the server per day

2. Search for media -> post request (sent to server with some search parameters – username, hastag, business name etc)

3. Server evaluates the search request and sends the request to the DB. DB does a look up for each search request. -> We say about 20 posts are returned per search and each 50% are photos and 50% are media(video), so about 10 photos and 10 videos per search are returned. Hence 4Billions videos and 4Billions photos are returned.

But about 40Billion videos and 40Billion videos are searched (assuming 10X data is stored and available on instagram).

Hence storage needs to be able to search through this vast amount of data and identify the top 20 results and return this playloads meta data with image back to the user in less than 1 second (server response requirement).