5 ms·
"According to the Sanic author’s benchmark, uvloop could power this beast to handle more than 33k requests/s which is just insane (and faster than node.js)." I
by gtirloni 10y ago
"According to the Sanic author’s benchmark, uvloop could power this beast to handle more than 33k requests/s which is just insane (and faster than node.js)."
I keep looking for excuses to focus on Python instead of Go and claims like this one make me happy. However, when I check the benchmarks I get confused:
http://www.techempower.com/benchmarks/#section=data-r13&hw=ph&test=fortune&b=2&s=1&l=4ft3pb http://www.techempower.com/benchmarks/#section=data-r13&hw=p...
Of course this looks amazing:
https://magic.io/blog/uvloop-blazing-fast-python-networking/ https://magic.io/blog/uvloop-blazing-fast-python-networking/
But, even if in the request/second area Python might be doing great now, won't there be problem down the line with the GIL? That is, isn't async/await an island of good performance?
- ddorian43 10y agoIt will be a problem with ~every library since python is slow by default (compared to go,java,etc)
- dom0 10y agoBig surprise that a hashtable-interpreter is slower than a compiled or heavily JITed runtime. I also heard that CPython is slower than assembler. I'm not sure why that is?
- jgalt212 10y ago> But, even if in the request/second area Python might be doing great now, won't there be problem down the line with the GIL? Yes, you'll probably have to move the really work down to a cluster based job queue.
- dom0 10y ago> won't there be problem down the line with the GIL? If you want parallelism in pure Python code, you don't use multiple threads.
- xapata 10y agoUnless you're on Jython or the parallelism is for I/O.
- dr_zoidberg 10y agoIt seems like Sanic isn't on that list, so you can't really check its authors claim with it.
- AdamN 10y agoSo rarely is speed actually needed. If you need the speed though, just write a library in C/Fortran/Go and call it from Python. That way you can do all your business logic where it's easy and very fast (Python) and still have room for crazy fast (Go, C) if you need it. Most real applications bottleneck in the database though, not the language.
- rcarmo 10y agoThe TechEmpower benchmarks should be taken with a grain of salt because, in the specific case of Python, and last year at least, they didn't seem to take into account real-life deployments (i.e., they're benchmarking raw scripts instead of a WSGI app running inside gunicorn or uwsgi, either of which has its own threading model and performance improvements). However, Go and Java will handily beat Python any day, even with uvloop -- all you need to do is try to do a little more processing inside your HTTP handler, aaaaannnnddd thiiiingggsss willl sloooowww dooooowwwwnnnn....
- tomnipotent 10y ago>> they're benchmarking raw scripts TechEmpower uses gunicorn/nginx [1] for Python frameworks, and has since 2014. >> all you need to do is try to do a little more processing inside your HTTP handler Unless you're working with an external service like a relational database, in which case performance between Go/Java and Python will be comparable [2]. If you don't need to leave your process, Go/Java will flatten Python. [1] https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Python/flask https://github.com/TechEmpower/FrameworkBenchmarks/tree/mast... [2] https://www.techempower.com/benchmarks/#section=data-r13&hw=ph&test=query&l=4ft3sv https://www.techempower.com/benchmarks/#section=data-r13&hw=...
- Bedon292 10y agoFor simple API things it definitely is significantly faster than anything else python has to offer. I am not sure where the author got the node comparison from, but all the python benchmarks are provided https://github.com/channelcat/sanic https://github.com/channelcat/sanic with the code used to run them. These are also single process benchmarks on a AWS medium (not sure what type). And I believe (best I can tell) those techempower benchmarks are run on a 40 core bare metal machine.