Discussion:
Python redis client performance
chinatian
2012-02-08 03:40:16 UTC
Permalink
Why do I use pure Python redis connection the redis db get speed is
only 10k / s, while redis-benckmark speed to 40k?
Didier Spezia
2012-02-08 15:14:01 UTC
Permalink
It may be because redis-benchmark is written in optimized C
which is 50 times faster than pure Python, and/or because
your Python script does not use pipelining or multiple
connections to limit the impact of network latency.

See http://redis.io/topics/benchmarks for more information.

Regards,
Didier.
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To view this discussion on the web visit https://groups.google.com/d/msg/redis-db/-/KZ_sbQsHm10J.
To post to this group, send email to redis-db-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to redis-db+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
lsbardel
2012-02-08 15:58:15 UTC
Permalink
You may also find an explanation in http://redis.io/topics/latency
Josiah Carlson
2012-02-08 16:47:19 UTC
Permalink
Are you using the optional hiredis accelerator and pipelines? With a
single connection, I can typically push 70% of redis-benchmark's speed
with Python + redis + hiredis + pipelines.

Regards,
- Josiah
Why do I use pure Python redis  connection the redis db get speed is
only 10k / s, while redis-benckmark speed to 40k?
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redis-db-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to redis-db+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
David Montgomery
2012-02-08 16:58:51 UTC
Permalink
Can you show how to use the hiredis accelerator and pipelines for a get and set?

I am new to python redis and will be using it a lot.

Thanks

On Thu, Feb 9, 2012 at 12:47 AM, Josiah Carlson
Post by Josiah Carlson
Are you using the optional hiredis accelerator and pipelines? With a
single connection, I can typically push 70% of redis-benchmark's speed
with Python + redis + hiredis + pipelines.
Regards,
 - Josiah
Why do I use pure Python redis  connection the redis db get speed is
only 10k / s, while redis-benckmark speed to 40k?
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redis-db-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to redis-db+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
Didier Spezia
2012-02-08 17:20:03 UTC
Permalink
Hi,

to use hiredis, you just have to install the hiredis package on top of the
redis python package.
It is then used automatically if it is present.

pip install redis
pip install hiredis

You can find an example of pipelining with Python in the documentation
at https://github.com/andymccurdy/redis-py
r = redis.Redis(...)
r.set('bing', 'baz')
# Use the pipeline() method to create a pipeline instance
pipe = r.pipeline()
# The following SET commands are buffered
pipe.set('foo', 'bar')
pipe.get('bing')
# the EXECUTE call sends all buffered commands to the server, returning
# a list of responses, one for each command.
pipe.execute()
[True, 'baz']


Here is another example in a larger script:
https://gist.github.com/1771342

Regards,
Didier.
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To view this discussion on the web visit https://groups.google.com/d/msg/redis-db/-/qQW8AA-TdskJ.
To post to this group, send email to redis-db-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to redis-db+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
Josiah Carlson
2012-02-08 19:22:42 UTC
Permalink
Also, if you want to bypass the multi/exec calls around it, and just
want to buffer your commands, you can use 'r.pipeline(False)' .

Regards,
- Josiah
Hi,
to use hiredis, you just have to install the hiredis package on top of the
redis python package.
It is then used automatically if it is present.
pip install redis
pip install hiredis
You can find an example of pipelining with Python in the documentation
at https://github.com/andymccurdy/redis-py
r = redis.Redis(...)
r.set('bing', 'baz')
# Use the pipeline() method to create a pipeline instance
pipe = r.pipeline()
# The following SET commands are buffered
pipe.set('foo', 'bar')
pipe.get('bing')
# the EXECUTE call sends all buffered commands to the server, returning
# a list of responses, one for each command.
pipe.execute()
[True, 'baz']
https://gist.github.com/1771342
Regards,
Didier.
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/redis-db/-/qQW8AA-TdskJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/redis-db?hl=en.
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redis-db-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to redis-db+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
Loading...