Kalyana Sundaram
Kalyana Sundaram

Reputation: 223

Sorting, union intersection across redis shards

I am new to redis. I need to know how sorting, intersection and other aggregate operations happen across shards. Is it possible to perform such operations?

Upvotes: 2

Views: 1064

Answers (1)

AlexGad
AlexGad

Reputation: 6692

Redis won't transparently handle this for you. You would need to basically retrieve the results from each shard and then reassemble them (assuming your search is on something other than the sharded key). Some libraries out there make sharding easier (see predis https://github.com/nrk/predis) with Redis. Basically, though, what you would do is run the query against all the shards, bring back the results and then merge the results, sort, intersect, aggregate, etc.

You may want to keep an eye on the Redis cluster project http://redis.io/topics/cluster-spec as it might provide what you want to achieve without sharding, although it is only in development at the moment.

Finally, you should also be aware that sharding does not provide any type of redundancy or facility to rebalance a shard when you add/remove new nodes. If a shard is gone, you lose all the data in that shard. This is fine if you are using Redis as a cache and not as the final authoritative store of your data. Because of this, make sure you consider master-slave replication of each shard as well.

Upvotes: 4

Related Questions