How To Make An App Like Instagram

Facebook's acquisition of Instagram for a billion dollars in 2012 was considered by investment analysts extravagant at the very least. However, by 2016 when Instagram was conservatively valued at $50B, the critics were claiming to be have been misquoted.

But how easy is it to build an app like Instagram?

The simple answer: It's not rocket science.  It is harder, far harder. I mean, pariah states have rocket scientists enough to build missileS, but there is only Instagram in the world.  And then there is that bit about Facebook preferring to pay a billion dollars instead of building another Instagram.

However, if some reason I wanted to build a similar app what would it take? It is an interesting question, and very instructive for both entrepreneurs who want to know how to build a Billion Dollar App and mobile application developers who want to build scalable applications.


Let's first at the business issues then the technical side of building mega applications. We will confine ourselves to the platforms before acquisition by Facebook when it's identity became inextricably linked with FB. 


Are You As Lucky?

Chance, Louis Pasteur, the Einstein of biology, reportedly said, favors the prepared mind. The biggest factor in Instagram's growth from start-up to a billion dollars was luck. Techcruch, describes the company as having nailed timing. And that is in retrospect. It was not disruptive, it was creative in the sense that it did not disrupt an industry but instead created it. However, there is more to the story than just luck.

Do Your Research

Instagram, or what became instagram was inspired by a growing popularity amongst iPhone users for location based applications. Further research by Systrom into check-in apps led him to Burbn, and the proverbial light bulb flashed. The trigger was photos. Burbn's users were sharing photos more often than they were checking-in. Instagram was still a concept when Systrom met Mike Krieger with  whom he co-founded Instagram. Together they examined hundreds of apps to identify a niche between on-line photo editing and outright social media. And built Instagram to build it.

Define The App

A software developer's nightmares typically feature scope creep. It is what happens when you start a custom software development project such a mobile application with “ I will know it when I see” attitude. Instagram's founders had defined their specs to pretty well. However, it still took months to develop the prototype- called Scotch. 

Get The Team

Mobile application development is not a trivial task. When it is a new concept, ground breaking technology and highly specialized who you choose to partner will break or make the app. The Instagram duo grew their team very slowly and were very choosy about who they chose to work with. For instance they refined objective-c development skills instead of hiring new developers.

The Technology Stack Backing Instagram

Any custom software development project is made or broken by the technology used to build it. For instance, in the journey to social media dominance Facebook has had to redefine NoSQL, create an Artificial Intelligence system and develop a new approach to Javascript that is ReactJS. One of the most amazing things that Instagram achieved as a start up was build a system supporting 20+ million users with only three system engineers in less than an year. 

Didn't hear someone ask how the hell did they do that? According to  Kreiger these were the guiding principles:


  1. KISS- Keep It Simple

  2. Use the tested and proven technologies when you can

  3. Don't reinvent the wheel


The Instagram Technology Stack Details:

Operating System and hosting

To launch an app, you need to get hosted. One of the radical decisions that defined Instagram was the choice to outsource hosting. They were one of the first companies to adopt Amazons Elastic Cloud in 2010. It was not smooth sailing, as before settling on cloud hosted Ubuntu 11.04, they had tried earlier versions that were prone to unpredictable bouts system freezing under high traffic.


This is an important lesson for anyone looking to develop the next big app: focus on the problem. Instead of trying to host themselves, which would diverted crucial financial and technical resources to non-core issues they chose to go with the tried and tested solutions.

By choosing to use Linux, which is open source and free, the start-up avoided committing resources to software licensing. In building a similar app, serious consideration should be given to outsourcing those aspects that are not core business.


If unlike the Instagram founders, you don't have a software development background, you might consider outsourcing development to a specialist mobile app development company and focus on your core competence.


Load Balancing

Remember where I said Instagram was lucky? Well, I followed up by quoting Louis Pasteur, on how chance favors the prepared. On it's first day, Instagram got 25,000 users and crossed the 6M mark in 90 days.  That is to say in it's first 90 days it averaged 70,000 new users a day. Many apps would crash and burn under such growth. So although they were lucky they were also prepared.


From the onset they built the system to scale up to mega usage. One way this was achieved was routing every single request through load balancing servers. At the start load balancing was achieved by using ngix servers implementing Round Robin DNS to route the request to the least loaded server.


However, the rapid growth made the time taken for DNS to update when a server were decommissioned or commissioned became a bottleneck. In response and as per their engineering principle  no 2 (Use tested and proven technologies) the team switched with to Amazon Elastic Load Balancer.  The load balancer was backed by 3 nginx machines that with automated health monitoring such that they could automatically recover from failure. 

In retrospect, the choices made by Instagram's engineers seem obvious. However, it instructive that they chose to do when the technologies were not exactly mature. Which brings up the next lesson for anyone embarking in software development projects: Software quality assurance is ongoing. Having started with scalable choices, Instagram's engineers were not content with that but continued to deal with issues as they emerged without forgetting that in software development, sophistication is synonymous with simplicity. 


Application Servers:

So how does the Instagram back-end run? Before the specifics? Let's look at the rationale: The Instagram value proposition is pretty simple: online picture album and editing. To achieve that, Kreiger and Systrom had to build easy to use photo filters.  While they started with IOS app development, they kept on their eyes on ultimate prize, easy cross platform mobile app development.  


Hindsight is 20 20, it has been said, but predicting the future is an imprecise art at best. When developing an app, to run on both android and iOS it easy to get distracted. The distraction is for instance, great  android app development or iOS app development at the cost of uniform and consistent UX across the platforms.


The approach chosen by Instagram to achieve true cross platform app development, colloquially defined as write once run everywhere, was to move most functionality to the back end or application servers. They built an architecture running Django (a Python framework) on Extra-Large Amazon's High-CPU machines. The rationale was that Instagram (picture editing) was a CPU intensive application not memory intensive. 


This approach allowed them elasticity since the machines are stateless and scalability as they could instantiate new machines on demand. Compare this to self hosting, in which the team would have had to buy servers and commit personnel to configure and manage them and it becomes obvious it was a winning proposition. 


Data storage

Well everyone knows pictures requires lots of memory. How does Instagram store 1.2 billion pictures uploaded on the app a day? Prior to buy out by Facebook, after which we can safely assume the app was moved to NoSQL, they used PostgreSQL.


The main cluster was 12 quadruple Extra large instances of Postgre replicated in a different zone.  The default Amazon network disk system was inadequate in respect to IO so they reconfigured it to use software RAID. Instagram optimized the system to manage in memory data so that in case a machine failed, the memory profile was moved from one machine to another using vmtouch.


Every android app developer, iOS developer and android application development company has trade secrets that they consider to be their competitive edge. One such secret, is how to optimize the connection to databases from app servers. Instagram optimization was to use Pgbouncer, a utility that allowed pooled connections to PostgreSQL.


The result is that the overhead in managing DB to app connections was drastically reduced, allowing for most of the system resources to be used to actually write and read from databases. The actual storage is on Amazon S3. It is coupled Amazon's CloudFront as content delivery network (CDN) for geographically smart routing that stored data close to users reduce loading times. 


Notification pushing and task queues

Instagram unique value proposition is providing better photo editing and allowing the editied photo's shared out to social media viz Twitter or Facebook. And successful mobile application development requires pushing notifications such as new photo uploads in case of Instagram.


They achieve that asynchronously through adding new tasks to (sharing or notifications) to a queue task system called Gearman. It allows these non real time tasks to be suspended when real time tasks such as photo-uploads arise. 


Monitoring

With multiple load balancers, database and application servers and replications how do you keep informed on what's happening and where? I once worked for an android development company that had over 50 apps to manage on behalf of clients.


I was tasked with monitoring and before learning how Instagram did it, my typical day was 14 hours of crisis management. Then I learnt about Munin, the Python based systems monitoring tool that Instagram uses and then I could do 2 hour lunch breaks before leaving the office early.


PagerDuty is another utility that Kreigers team co-opted for monitoring notification and incident management. At application level they used Sentry which is native to Django and written by Disqus team. 


Mobile Apps

Instagram is a cross platform mobile app that offers uniform UX across all platforms. However, it was initially available only on iOS which used indepth knowledge of objective-C plus skilled swift developers and objective-c developers.


The android app that came later, used a lot of native features not available in HTML 5 or slow when available to match the iOS UX. This was achieved using android development tools of Java and XML. The latest version of Instagram apps bounders on augmented reality app development.  


Design And User Interface:

The inspiration for Instagram was Burbn, a check-in app and Hipstamatic a photography app. However, this bags the question: How did Instagram make it and these apps fail? The System identified the niche but Krieger that built the app.


The first version of Instagram never made it to iTunes because they felt it was too slow and functionality was not ready yet,. The secret was a great UX which in the first publicly released version, was minimalistic. A user could post a photo in just three clicks. 


These shows what  many an early iOS app developer had to learn and is now common knowledge in the industry. The product is as important as the UX. In fact, an average app with a great UX will in most cases out perform a great app with average UX.


The Billion Dollar Question; Cost.

So how much does it cost to develop an app like Instagram? Simple answer: A billion dollars. Well, not exactly. But when Facebook paid $1B for Instagram it showed that they thought it was cheaper than developing a similar app. However, they also were paying for the brand not just reimbursing development costs. So actual development costs would be significantly less. 


Thank you for reading.

Do well to drop comments or questions.

Comments