asyncio-redis icon indicating copy to clipboard operation
asyncio-redis copied to clipboard

Missing Pipeline support ?

Open niteeshm opened this issue 8 years ago • 3 comments

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 :

  1. 10000 hgetall calls in parallel - 3.7037110328674316s
  2. 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 ?

niteeshm avatar Jan 26 '17 12:01 niteeshm

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

etataurov avatar Jan 30 '17 15:01 etataurov

Following up, is anyone working on pipeline support or are you looking for contributors?

0x-2a avatar Oct 02 '18 12:10 0x-2a

+1

Gpzim98 avatar Feb 26 '19 11:02 Gpzim98