On Wed, Jan 8, 2014 at 7:28 PM, Josiah Carlson <
josiah....@gmail.com> wrote:
> My first suggestion would be to use the MGET command, which I benchmark to
> be significantly faster than pipelined GET requests (2-10x, depending on
> clients). You can also pipeline MGET requests for the full effect.
>
> Whether or not sharding will substantially help performance will depend on
> whether or not you can saturate your one Redis process. Do you know your
> required QPS? Expected growth?
>
I (was) in a similar situation where I needed to fetch lot of keys at
the same time.
Redis is spending more time parsing and reading MGET commands /
pipelined GET than executing them.
The solution is to avoid sending long strings through sockets to enjoy
very fast Redis:
total_commands_processed:2559986635
keyspace_hits:1340709160158
There are 2 ways for this:
- Implement in C inside Redis
- Implement in LUA
Let's say you have keys like this: "field2130" "field2131" "field2132"
"field2133" "field2134" "field2135" "field2136" and you want to SUM
them, you can just write a simple loop:
for (i = 2130; i <= 2136; i++)
{
robj *o = lookupKeyRead(c->db, startKey);
if (o != NULL) {
total += (long)(o->ptr);
}
incrKeyName((char*)startKey->ptr); <---- your function here
}
addReplyLongLong(c, total);
and voila.
Arnaud.