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

Optimize the multi-bulk reply handling

Open mikegreen7892003 opened this issue 11 years ago • 9 comments

SyncMset is much quicker than AsyncMset. Is that right?

I ran the demos/benchmark/app.py and found that SyncMset is much quicker than AsyncMset. Is it work right? My logging: INFO:tornado.access:200 GET /redis-py/mset (192.168.1.100) 83.39ms WARNING:tornado.access:404 GET /favicon.ico (192.168.1.100) 0.41ms INFO:tornado.access:200 GET /mset (192.168.1.100) 1736.85ms WARNING:tornado.access:404 GET /favicon.ico (192.168.1.100) 0.40ms

I installed tornado, redis, redis-py, torando-redis today. tornado version is 3.0.1. redis-py version is 2.7.5. tornado-redis version 2.4.2. Redis server v=2.6.13 sha=00000000:0 malloc=jemalloc-3.2.0 bits=32

By the way, my linux version is "centOS 6.2(Final)" and "kernel linux 2.6.32-220.e16.i686".

mikegreen7892003 avatar Jun 02 '13 16:06 mikegreen7892003

Yes, you're right. The processing of the multi-bulk replies if far more efficient in redis-py client.

I'll add a note on Redis client usage to the README file to indicate it.

leporo avatar Jun 03 '13 06:06 leporo

Thank you very much. I guess the reason is because the use of hiredis. :+1:

mikegreen7892003 avatar Jun 03 '13 07:06 mikegreen7892003

No. Tornado-redis is MUCH slower even if hiredis is not being used by redis-py. The current implementation of multi-bulk reply processing in tornado-redis creates a callback to virtually every received byte of data and this is the main reason of such a poor performance.

I plan to refactor this code and add the hiredis support to tornado-redis.

However, at this moment it's better to use redis-py for non-blocking commands.

leporo avatar Jun 03 '13 07:06 leporo

Don't you mind if I rename the issue to 'Optimize the multi-bulk reply handling'?

leporo avatar Jun 04 '13 07:06 leporo

how to use redis-py for non-blocking pub-sub command??

goldalworming avatar Jun 04 '13 08:06 goldalworming

I suggest using tornado-redis for these. Please check this websockets demo: https://github.com/leporo/tornado-redis/tree/master/demos/websockets

But you may use redis-py in your Tornado application for GET's, MGET's and other non-blocking commands and get the faster and easier-to-maintain code.

leporo avatar Jun 04 '13 09:06 leporo

I've added a note to the README file on this matter: https://github.com/leporo/tornado-redis#tornado-redis-vs-redis-py

leporo avatar Jun 04 '13 09:06 leporo

Thank you for your kindness. I don't mind you rename the issue. I'm also excited about how the performance changes after the issue be finished.

mikegreen7892003 avatar Jun 04 '13 10:06 mikegreen7892003

ok thank you..because I don't get better implemetation redis pub/sub beside this library combination is a good choice..

thanks

goldalworming avatar Jun 04 '13 10:06 goldalworming