Instagram scaled from 0 to 14 million users in just over a year, from October 2010 to December 2011. They did this with only 3 engineers. (View Highlight)
Session: After opening the app, a request to grab the main feed photos is sent to the backend, where it hits Instagramâs load balancer. (View Highlight)
Session: The application server grabs the latest relevant photo IDs from Postgres. (View Highlight)
An interesting challenge that Instagram faced and solved is generating IDs that could be sorted by time. Their resulting sortable-by-time IDs looked like this: (View Highlight)
41 bits for time in milliseconds (gives us 41 years of IDs with a custom epoch) (View Highlight)
13 bits that represent the logical shard ID (View Highlight)
10 bits that represent an auto-incrementing sequence, modulus 1024. This means we can generate 1024 IDs, per shard, per millisecond (View Highlight)
Thanks to the sortable-by-time IDs in Postgres, the application server has successfully received the latest relevant photo IDs. (View Highlight)
Session: To get the user data from Postgres, the application server (Django) matches photo IDs to user IDs using Redis. (View Highlight)
Instagram used Redis to store a mapping of about 300 million photos to the user ID that created them, in order to know which shard to query when getting photos for the main feed, activity feed, (View Highlight)
For general caching, Instagram used Memcached. They had 6 Memcached instances at the time. Memcached is relatively simple to layer over Django. (View Highlight)
Session: The user now sees the home feed, populated with the latest pictures from people he is following. (View Highlight)
Pyapns is an open-source, universal Apple Push Notification Service (APNS) provider. (View Highlight)
Session: The user really liked this photo! So he decided to share it on Twitter. (View Highlight)
Session: Uh oh! The Instagram app crashed because something erred on the server and sent an erroneous response. The three Instagram engineers get alerted instantly. (View Highlight)