anhtran
anhtran

Reputation: 2034

Deploy redis on many servers

My web application is using redis for the main database. It's very nice in performance. At this time, my database is too big and I want to add some new servers for storage. But I still stuck in the solution how to distribute in stable and easy to backup.

Everyone has any ideas?

Thanks a lot!

Upvotes: 1

Views: 1246

Answers (2)

Schmurfy
Schmurfy

Reputation: 1725

From what I understand there is no automatic way of doing this built into redis itself (and it's hard to implementa generic way since it depends what your application will do with these data), you have to do this yourself (or in the driver like the ruby driver does).

I think your best bet is to put that logic in your application, without any knowledge of your application it is hard to say precisely but you may decide that the first part of your ids decide which redis server the key will be stored.

The ruby driver simply try to distribute the keys among the servers or takes the server index from the key name if formatted accordingly (something like "{server_id}mykey" after a quick glance at the code)

[Edit] Possible solution: - https://github.com/gmr/mredis

Upvotes: 2

Theo
Theo

Reputation: 132862

You don't mention which language you use. If it's Ruby then the driver has a client side sharding solution, which solves many problems. antirez is working on a cluster solution for Redis, but it is still unfinished.

Neither client side sharding nor Redis cluster can solve every problem though. If you, for example, need to do unions and intersections of sets you can't do that unless both sets happen to reside in the same shard (I believe Redis cluster will have some means to handle this, but not automatically).

Yet another solution is Redis diskstore, but just like the clustering it is not yet finished. Diskstore would mean that you can grow your dataset larger than RAM, and use replication to scale reads.

Upvotes: 2

Related Questions