asyncio-redis
asyncio-redis copied to clipboard
Missing Pipeline support ?
Even though mentioned on the home that pipelining support is there in the library, I haven't been able to use it or find any reference in the code. Can i not use pipeline as simply as :
pipe = await conn.pipeline()
pipe.hgetall("key1")
pipe.get("key2")
results = await pipe.execute()
Also, if I execute 3 redis commands in parallel using asyncio.gather
and 3 commands pipelined , which will be faster ?
I did a small benchmark, where I am reading 10000 keys using asyncio.gather concurrently and serially. These were the numbers :
- 10000 hgetall calls in parallel - 3.7037110328674316s
- 10000 hgetall calls sequentially - 0.9311599731445312s
This is strange no?
Here is the code -
Parallel
async def fetch(key):
return await conn.hgetall(key)
await asyncio.gather(*[fetch('my_key') for i in range(10000)])
Serial
[r.hgetall('my_key') for i in range(10000)]
Where am I going wrong ?
Hi!
Your serial example doesn't look correct, it doesn't await for result.
for python3.6 it should be
[await conn.hgetall('my_key') for i in range(10000]
Having 10000 request in parallel might be faster than sequentially if you use connection pool with 10000 connections, otherwise you block on awaiting for connection release.
yes, unfortunately, pipeline support is not implemented and there is no mention in README
Following up, is anyone working on pipeline support or are you looking for contributors?
+1