“How Instagram Is Using Django And Python”- Instagram has become everyones favourite social media channel when seamless numberof posts and profiles can be seen can can be chit chatted at one place. Basically, its a space with infinite things.
However lets now look into what is behind the scenes in making of Instagram and how our Python and Django framework plays a role in making such a powerful tool.
Contents of Tutorial
Background and Introduction :
Instagram was developed in San Francisco by Kevin Systrom and Mike Krieger. Systrom was working in marketing and started doing engineering at night to help him learn how to code. He created a prototype app of an idea he originally called Burbn, which allowed people to check-in where they are on their mobile web app.
What is Django?
Django is a free and open source web application framework, written in Python. A web framework is a set of components that helps you to develop websites faster and easier.
When you’re building a website, you always need a similar set of components: a way to handle user authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to upload files, etc.
Lets now look into how Instagram uses these Python frameworks.
Use of Python Frameworks in Instagram :
Instagram utilizes Django which is a Python web structure. It is the best structure you can learn in light of the fact that as a designer if the venture is created by one group from the earliest starting point as far as possible, you can without much of a stretch change it anyplace in the center. Django is in truth an extraordinary open source structure composed on Python language that is tried and true. Django has made it simpler for designers to assemble a plenty of web applications, website pages and web administrations. Instagram began in 2010 and a couple of months after the fact they had 1 million clients. Django was an extremely advantageous arrangement to manufacture Instagram in it.
- Django is designed to help the developers make an application as quick as possible.
- For error reporting in Instagram, Sentry is used which is an open source Django app written by the team at Disqus. A database of 5 million users is managed by Django ORM in the year 2010.
- Django is the core of Instagram.
- Although a massive 5 million users is managed by Django ORM now, Instagram starts quickly as it is accessed because it uses Django which is tightly integrated.
- The ORM can be replaced if Django is loosely coupled enough. The fun fact is that all Instagram and Facebook employees are allowed to contribute code to Django.
- The whole of this amazing platform is written entirely in Python. To be precise Instagram features the world’s largest deployment of Django web framework.
The following are official data provided by Instagram regarding their use of Python.
1- Thrash and data Management :
At Instagram, they have the world’s largest deployment of the Django web framework, which is written entirely in Python. They began using Python early on because of its simplicity, but had to do many hacks over the years to keep it simple as we’ve scaled. Last year developers tried dismissing the Python garbage collection (GC) mechanism (which reclaims memory by collecting and freeing unused data), and gained 10% more capacity. However, as engineering team and number of features have continued to grow, so has memory usage. Eventually, they started losing the gains they had achieved by disabling GC.
Here’s a graph that shows how memory grew with the number of requests. After 3,000 requests, the process used ~600MB more memory. More importantly, the trend was linear.
From load test, it could be seen that memory usage was becoming bottleneck. Enabling GC could alleviate this problem and slow down the memory growth, but undesired Copy-on-write (COW) would still increase the overall memory footprint. So they decided to see if hey could make Python GC work without COW, and hence, the memory overhead.
2- Web service effeciency :
Instagram currently features the world’s largest deployment of the Django web framework, which is written entirely in Python. We initially chose to use Python because of its reputation for simplicity and practicality, which aligns well with our philosophy of “do the simple thing first.” But simplicity can come with a tradeoff efficiency. Instagram has doubled in size over the last two years and recently crossed 500 million users, so there is a strong need to maximize web service efficiency so that our platform can continue to scale smoothly. In the past year we’ve made our efficiency program a priority, and over the last six months we’ve been able to maintain our user growth without adding new capacity to our Django tiers. In this post, we’ll share some of the tools we built and how we use them to optimize our daily deployment flow.
So, The above are some of the uses of Python in Instagram, the powerful tool built in Python.