Live data from Hacker News

Uvloop: Fast Python networking

magic.io

21–30 of 132 posts

Re: Uvloop: Fast Python networking

#21
post #18

Also note that David Beazley (google him if you're not aware) has a competitor to asyncio, which arguably is also a direct competitor to this called curio: http://curio.readthedocs.io/en/latest/ The caveat is that it uses the new async/await coroutine bits that just landed in Python 3.5, so it only works with Python 3.5+. He also gave a talk on concurrency in python recently at last year's PyCon: https://www.youtube.…

There are benchmarks of curio in the blog post, FWIW.

Re: Uvloop: Fast Python networking

#22
post #2

I'm the dev behind uvloop. AMA.

do you have perf benchmarks under heavier concurrency? (e.g., how does it do with 100 concurrent clients? 1000?)

The HTTP benchmarks were actually run under concurrency level of 300. I've just updated the post with extra details. See also the full report of HTTP benchmark [1]

[1] http://magic.io/blog/uvloop-blazing-fast-python-networking/h...

Re: Uvloop: Fast Python networking

#23
post #20
post #11

This is quite interesting, but I don't find req/sec very interesting at all. These should be about matters of concurrency, that is, how much is being done at once, not how many req/sec overall are done (which could almost be explained away purely by the gains in lower latency). These benchmarks seem to only use 10 clients concurrently, max. That's ridiculously low. A few questions I'd like to see answered. How many c…

> These benchmarks seem to only use 10 clients concurrently, max. That's ridiculously low. I've just update the post with more details on HTTP benchmarks and attached the correct full-results file [1]. The concurrency level for HTTP benchmarks is 300, not 10. To answer other questions, I'll have to run some benchmarks tomorrow :) [1] http://magic.io/blog/uvloop-blazing-fast-python-networking/h...

Cool! For the client test I'm referring to, these would be long-lived clients that stay around and just TCP ping for an echo server, rather than HTTP calls that connect/disconnect.

In my experience, PyPy+twisted is around 5-25x faster CPython/twisted, and smoked asyncio as well. Would be great to see how uvloop compares there, and of course, someday when PyPy supports Python 3.5, there's no reason it couldn't use uvloop via cffi I'd hope.

Re: Uvloop: Fast Python networking

#24
It is interesting that uvloop-streams is almost identical to gevent in performance. Gevent is based on libev, the project libuv was forked from.

What exactly is the -streams addition that makes uvloop-streams perform so much worse than plain uvloop?

Re: Uvloop: Fast Python networking

#25
post #18

Also note that David Beazley (google him if you're not aware) has a competitor to asyncio, which arguably is also a direct competitor to this called curio: http://curio.readthedocs.io/en/latest/ The caveat is that it uses the new async/await coroutine bits that just landed in Python 3.5, so it only works with Python 3.5+. He also gave a talk on concurrency in python recently at last year's PyCon: https://www.youtube.…

Unless I'm mistaken, the decorator @asyncio.coroutine() is equivalent to async def and yield from is functionally a drop-in for await, so you should be able to use it with at least 3.4, maybe 3.3. Not that that's much better though.

Re: Uvloop: Fast Python networking

#26
post #23
post #20

Earlier quoted context omitted.

> These benchmarks seem to only use 10 clients concurrently, max. That's ridiculously low. I've just update the post with more details on HTTP benchmarks and attached the correct full-results file [1]. The concurrency level for HTTP benchmarks is 300, not 10. To answer other questions, I'll have to run some benchmarks tomorrow :) [1] http://magic.io/blog/uvloop-blazing-fast-python-networking/h...

Cool! For the client test I'm referring to, these would be long-lived clients that stay around and just TCP ping for an echo server, rather than HTTP calls that connect/disconnect. In my experience, PyPy+twisted is around 5-25x faster CPython/twisted, and smoked asyncio as well. Would be great to see how uvloop compares there, and of course, someday when PyPy supports Python 3.5, there's no reason it couldn't use uvl…

> [..] Would be great to see how uvloop compares there [..]

Yep, I'm curious to see what will happen there. Do you have any suggestions on what tool to use to generate the load?

> [..] someday when PyPy supports Python 3.5, there's no reason it couldn't use uvloop via cffi I'd hope.

We'll figure that out! ;)

Re: Uvloop: Fast Python networking

#28
post #6

Earlier quoted context omitted.

> at least 2x faster than nodejs, gevent, as well as any other Python asynchronous framework I did not see any benchmarks in the repo to support this. How was this statistic determined?

Building on to this, how does it compare to raw libuv in c?Personally, I'm not surprised that python (especially cython) is faster than node in this case, but I still need to see how much less overhead there is to node.

> Building on to this, how does it compare to raw libuv in c?

Building something in C is very hard. uvloop wraps all libuv primitives in Python objects which know how to manage the memory safely (i.e. not to "free" something before libuv is done with it). So development time wise, uvloop is much better.

As for the performance, I guess you'd be able to squeeze another 5-15% if you write the echo server in C.

> I'm not surprised that python (especially cython) is faster than node in this case

Cython is a statically typed compiled language, it can be anywhere from 2x to 100x faster than CPython.

Re: Uvloop: Fast Python networking

#30
post #2

I'm the dev behind uvloop. AMA.

1) What makes uvloop which is based on libuv 2x faster than node.js which is also based on libuv? 2) Can uvloop be used with frameworks like flask or django? 3) gevent uses monkey patching to turn blocking libraries such as DB drivers non-blocking, does uvloop do anything similar? If not how does it work with blocking libraries?

1) I don't know :( I've answered a similar question in this thread with a couple of guesses.

2) No, they have a different architecture. Although I heard that there is a project to integrate asyncio into django to get websockets and http/2.

3) asyncio/uvloop require you to use explicit async/await. So, unfortunately, the existing networking code that isn't built for asyncio can't be reused. On the bright side, there are so many asyncio DB drivers and other modules now!

Post reply on HN