Web Service Efficiency at Instagram with Python
engineering.instagram.com
engineering.instagram.com
For lazy people: he wrote South, Django migrations and he's currently working on Channels.
I'm not knowledgeable about open-source issues, pros/cons, etc., but man... only 19% of $200K. Doesn't seem right given Python is one of the major languages and I believe Django is the most popular web framework in Python.
200k/year should be collected in no time...
I think a guide on how to get your company involved in donating to OSS projects would be beneficial. Has anyone come across any good advice, or have any experience in influencing your employer to donate?
I think the problem in many cases is that the finance and legal people at companies big enough to make a sizable donation are so busy that stuff like this never makes it to the front of their priority queue.
This, at least, is the implicit policy at the company I work for. It's used in the pitch ("we use and contribute to open source software, which we believe leads to a better internet" and so on) to the clients who appreciate such things.
That said, there might be too much legal tape to get that into a contract.
A is a company, B is an individual with lots of spare time.
B feels that he can help the company by writing a tool for them. He also envisions that the tool could be used by other companies and so wants to open source it so he can provide services around the tool.
B says to A : see, I'm going to develop the tool for you for free, in exchange you test it.
Note the tool is the n-th implementation of common business practices, such as an ERP. The tool is not about something specific to A.
B thinks : I'm independent, I'm not hired by A, I write the code as free software as it pleases me.
A then says : wtf? you're going to publish that code on the web ? Therefore my competitor might get it so, no way. I'd be liable for giving away some value of the company to the competitor
So, instead of saying something like "hey, I use that program so let's fund it a little", A actually says "by helping B to develop the program, I may actually help my competitors, I'm in legal trouble".
B is somewhat screwed :-(
(I let you figure out if this actually happened to me :-))
I also believe that Instagram needs Django to be OSS, and the same goes for any other framework/language/library that other companies use, as OSS in itself is an extremely powerful label for a project. It brings together developers to form a community with lots of great minds and inputs. It helps feasible projects become production-ready and stable much faster than if it was closed source as its use-cases are far more wider than what a single company would provide.
Taking this from a competetive standpoint isn't very realistic in my opinion. I dare say that if either Django or Python weren't open source software, Instagram wouldn't be built on it in the first place.
I think it's absurd how Instagram can grow financially fat from the hard work of the Django Software Foundation without even contributing a dime to their fundraising or provide engineers exclusively to the DSF. IMHO Instagram should bring that fundraising up to at least 100%, considering Instagram revenue is estimated to hit $5.8 billion USD by 2020, $160,000 USD per year is a small price for the amount of value Django brings them.
It's a topic of morale though, Instagram does not owe the DSF anything, but I guess this shows where Instagrams appreciation lies.
>>> It's a topic of morale though, Instagram does not owe the DSF anything, but I guess this shows where Instagrams appreciation lies.
That's the point I was actually making. My experience that when you have people brainwashed with "competitive advantage", "profit maximization", and such, well, morale just doesn't exist anymore. In my case, I was surprised to see how quickly someone I trusted can actually switch to this brainwashed brain...
Look at the PSF budget, it's so small it makes you cry.
* Let's stop talking about 'Donations' and start talking about 'Investment' - the conversation needs to be about the pay-off that businesses will get, not some altruistic "give-back"
* Make the case that collaborative investment has a great cost-reward, as the cost is spread over a bunch of companies.
* Make it clear that ecosystems that are well invested will be more competitive that those that are not. If your company has $$$ worth of engineers experienced in Django, you'd be daft not to ensure that Django remains competitive vs other frameworks.
It's an atypical pitch to make, and as with all investments it's difficult for folks to judge, because the pay-off is at a distance. I still believe it's still possible for us to change how collaboratively funded OSS is seen, once companies start to recognize well-invested ecosystems as a competitive advantage.
And yeah, this is pretty much the pitch I'm making for funding Django REST framework, where I'm currently 1/3 of the way towards being able to focus on it 100% of the time, with a full-time salary... https://fund.django-rest-framework.org/topics/funding/
> Instagram currently features the world’s largest deployment of the Django web framework
I think it is fair to assume that they use Django pretty heavily from that.
"Compared to CPU time, CPU instruction is a better metric,
as it reports the same numbers regardless of CPU models
and CPU loads for the same request."
CPU instructions will be more stable than CPU time for sure, and
it does show that their metric is stable based on their
chart but a single CPU instruction can take multiple cycles, especially
if there are stalls in the pipeline or other processes are "polluting"
the cache. Depending on the CPU model, the number of uops that can be issued
concurrently varies, and the latency of these instructions will also vary on
the size, and access pattern to their memory hierarchy.Also, what about a change in compiler version? That can also vary the number of instructions. Unless they are referring to a Python bytecode instruction as a CPU instruction.
Would measuring CPI be a better indicative of their efficiency? They could also track both, no need to settle for one.
Granted, I don't use python anymore for Web dev. I'm using languages that can handle 10x the traffic per box that Django used to be able to handle. This isn't a knick against python. I love python. Just such a different perspective.
- You are essentially maxing out incoming and outgoing network IO
- You have no database to speak to (or your DB is in-memory)
In that case, I guess it is just a race to do some computation and fetch the right data from RAM, then the limiting factors would be RAM access and the number of the computations you could do to try and keep up with inbound requests?
I guess what I'm really asking is what pros and cons are there with using dynamic and relatively slow languages compared to faster languages like C++, Java, or C#? My uninformed reaction is that it's easy for startups to get started with these easy languages but that it leads to problems when it's time to scale up. Dropbox is writing their own Python implementation, and Facebook have their PHP to C++ compiler.
I guess one thing you have to consider is
1. How many engineers do you have to hire to make Python "fast enough"
vs
2. What does it cost to deploy a full C++ team? Is it easier for new programmers to learn & write safe C++ code vs. Python.
I wonder what is cheaper?
s/C\+\+/golang/gNot sure how often that's the case in Instagram's use, but I've been using Python and Twisted to saturate network interfaces effectively since 2003 :-), and in those situations I've been more interested in the correctness advantages of a good statically-typed language rather than the performance.
If I were about high speed, I'd take Java (which regularly rivals, and sometimes surpasses, C++ in speed), or Rust, or maybe Go. Other worthy contenders would be Haskell, OCaml, D, maybe even Elixir (unless they are CPU-heavy), though with these hiring becomes much harder than with Python or Java (and probably even C++).
I like to think of the thousands of developers involved. ;)
For example, assuming Instagram uses gcc to build Python or any of the other components, gcc started in 1987.
Parts of glibc have copyrights dating from the 1980s, like netinet/tcp.h Copyright (c) 1982, The Regents of the University of California .
3 weeks in, I find myself loading my app's API client page to see if it's still stuck in a greyed out "go live" mode.
I've got an "Instagram API" search saved for twitter and StackOverflow to check checking if anyone else gets to slip through but others struggle just as much.
Just a little transparency and predictability is all that we ask for.
But I know that they will have their rough edge cases and developers banging their heads on the desk making this custom code for their needs.
But the grass does seem greener today :-)