Python vs Go - Requests per Second(dustinrcollins.com) |
Python vs Go - Requests per Second(dustinrcollins.com) |
Some people here are very dismissive of benchmarking in general, but if you are interested in evaluating programming languages for use in web applications, you would be interested in TechEmpower benchmarks, which are very thorough. [0] You can even send pull requests with updated languages, frameworks, or better implementations of different tests to give more competitive/accurate results. Enjoy.
[0] http://www.techempower.com/benchmarks/ [1] https://github.com/TechEmpower/FrameworkBenchmarks
UPDATE: Fixed link to the benchmarks.
OP: I recommend installing and using Wrk for web-server benchmarks. The Apache Bench tool (ab) is single-threaded and with today's higher-performance frameworks and platforms, Apache Bench itself can be a limiting factor in tests. See a reply I wrote elsewhere [1] for more information.
What about:
* Flask? http://flask.pocoo.org/
* Tornado? http://www.tornadoweb.org/en/stable/
* Django? https://www.djangoproject.com/
* CherryPy? http://www.cherrypy.org/
What about using PyPy ( http://pypy.org/ ), Jython ( http://www.jython.org/ ) or even IronPython ( http://ironpython.net/ ) instead of plain CPython?
Does anybody use PyPy, Jython or IronPython for a production web service? I'm seriously wondering. I've had the misfortune of having had to use Jython, but just to read Python pickles from a Java service (don't ask). Even that simple use case wasn't fun (the last stable release was also over a year ago).
PyPy looks great for small or new projects, but there is this disclaimer: "PyPy has alpha/beta-level support for the CPython C API, however, as of 2.1 release this feature is not yet complete. Many libraries will require a bit of effort to work..." - this has caused PyPy to be incompatible with every large Python project I've ever worked on.
And well, personal (dis)taste in .NET aside, IronPython hasn't had a release in over a year either...
Where are these projects being used in production?
http://www.quora.com/Alex-Gaynor/Posts/Quora-is-now-running-...
HTTP server: https://github.com/jonashaag/bjoern
import bjoern, json
def home_app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
s = {'name': 'A Royal Baby', 'body':'A slow news week'}
yield json.dumps(s)
bjoern.run(home_app, '127.0.0.1', 8086)I wish more people knew / recognized / accepted this understanding of Python's goals. There is the old but still quite accurate: http://www.python.org/doc/essays/comparisons/
I'm not sure if Guido is the original author, but he at least comments on it. There are also quite a few excerpts going back to the origins of Python where Guido plainly states that the goals of the language are ease, brevity and developer productivity - I've never seen performance as a stated goal.
I may be wrong, but that's all I see from this. (Assuming architecture >> micro benchmarks)
I'd say from the numbers I've seen this benchmark is not an unreasonable display of the performance difference between go and python.
If you are however, a Google-related person, notice that there is much too much Go around, at least here on HN. Maybe it's better to tune it down a little bit, otherwise it might induce a negative effect.
Unless one compares implementations of the same nature, it is obvious that the compiled one, in this case Go, it will always be faster.
Why bother at all to find out the obvious?!
I'm even more skeptical now that I see a company tried moving to PyPy, and actually hired a core PyPy developer (Alex Gaynor - http://pypy.org/people.html) to make the move, and it still didn't work out.
What I did find is current Disqus adventures in Go due to Python not being performant enough:
http://blog.disqus.com/post/51155103801/trying-out-this-go-t...
Of course there are some optimization strategies available for pythons, but you have infrastructure complexity depth and so many places where things can break. Beside the optimizations apply only to what can be optimized (static page cache).
Python has a fast code/test/run loop cycle, but Go and D have that now as well with the additional benefit of being fast.
These are the reasons why I decided to leave Python and go for the Go or D route. And I don't see why Go or D couldn't provide a web server as fast as nginx one day.