Today, I read an article about uvloop. I am aware of libuv and its behind nodejs. What caught me was “In fact, it is at least 2x faster than any other Python asynchronous framework.”. So I decided to give it a try with aiohttp.
The test program was simple websocket code which receives a text message, doubles the content and echoes back. Here is the complete snippet with uvloop.
I ran naive benchmark using thor and results favoured uvloop.
- uvloop was able to handle more connection on 8GB, non SSD Mac OSX. Asyncio was able to hold 154 connections and uvloop 243 connections with any socket errors.
- Response time for 154 connections, 10 messages for each connection took 1030ms in asyncio event loop and 915ms in uvloop. This is not full blown proper benchmark but proves the point.
If you haven’t tried asyncio, you should!
- Parameterize Python Tests
- “Don’t touch your face” - Neural Network will warn you
- Capture all browser HTTP[s] calls to load a web page
- How long do Python Postgres tools take to load data?
- Debugging Python multiprocessing program with strace
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.