Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Redis support strong consistency

I am looking at porting a Java application to .NET, the application currently uses EhCache quite heavily and insists that it wants to support strong consistency (http://ehcache.org/documentation/get-started/consistency-options).

I am would like to use Redis in place of EhCache but does Redis support strong consistency or just support eventual consistency?

I've seen talk of a Redis Cluster but I guess this is a little way off release yet.

Or am I looking at this wrong? If Redis instance sat on a different server altogether and served two frontend servers how big could it get before we'd need to look at a Master / Slave style affair?

like image 920
Steve Newstead Avatar asked Dec 03 '12 10:12

Steve Newstead


People also ask

Does Redis use consistent hashing?

Redis cluster uses a form of composite partitioning called consistent hashing that calculates what Redis instance the particular key shall be assigned to. This concept is called a hash slot in the Redis Cluster. The key space is partitioned across the different masters in the cluster.

Is Redis scalable?

There are two ways to scale your Redis (cluster mode enabled) cluster; horizontal and vertical scaling. Horizontal scaling allows you to change the number of node groups (shards) in the replication group by adding or removing node groups (shards).

What is strong consistency model?

Strong consistency is one of the consistency models used in the domain of concurrent programming (e.g., in distributed shared memory, distributed transactions). The protocol is said to support strong consistency if: All accesses are seen by all parallel processes (or nodes, processors, etc.)

Is Redis as fast as memory?

Redis is a remote data structure server. It is certainly slower than just storing the data in local memory (since it involves socket roundtrips to fetch/store the data).


1 Answers

A single instance of Redis is consistent. There are options for consistency across many instances. @antirez (Redis developer) recently wrote a blog post, Redis data model and eventual consistency, and recommended Twemproxy for sharding Redis, which would give you consistency over many instances.

I don't know EhCache, so can't comment on whether Redis is a suitable replacement. One potential problem (porting to .NET) with Twemproxy is it seems to only run on Linux.

How big can a single Redis instance get? Depends on how much RAM you have. How quickly will it get this big? Depends on how your data looks.

That said, in my experience Redis stores data quite efficiently. One app I have holds info for 200k users, 20k articles, all relationships between objects, weekly leader boards, stats, etc. (330k keys in total) in 400mb of RAM.

Redis is easy to use and fun to work with. Try it out and see if it meets your needs. If you do decide to use it and might one day want to shard, shard your data from the beginning.

like image 128
myanimal Avatar answered Sep 28 '22 09:09

myanimal