Does Redis support strong consistency

22,639

Solution 1

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.

Solution 2

Redis is not strongly consistent out of the box. You will probably need to apply 3rd party solutions to make it consistent. Here is a quote from docs:

Write safety Redis Cluster uses asynchronous replication between nodes, and last failover wins implicit merge function. This means that the last elected master dataset eventually replaces all the other replicas. There is always a window of time when it is possible to lose writes during partitions. However these windows are very different in the case of a client that is connected to the majority of masters, and a client that is connected to the minority of masters.

Usually you need to have synchronous replication to achieve strong consistence in a distributed partitioned systems.

Share:
22,639
Steve Newstead
Author by

Steve Newstead

Solutions Architect specialising in Sitecore. Working for Eduserv in a bid to make public good organisations make better use of their IT systems.

Updated on May 19, 2020

Comments

  • Steve Newstead
    Steve Newstead about 4 years

    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?

  • Steve Newstead
    Steve Newstead over 11 years
    Thanks, that gives me more than enough to go on!
  • jocull
    jocull about 5 years
    This is an old answer at this point, so notes about Twemproxy are likely not applicable since there is a standard Redis sharding option now :)