Redis or Ehcache?

You will meet issues with EhCache scaling and need resources to manage it during failover and etc. Redis benefits over EhCache:

  1. It uses time proven gossip protocol for Node discovery and synchronization.
  2. Availability of fully managed services like AWS ElastiCache, Azure Redis Cache. Such services offers full automation, support and management of Redis, so developers can focus on their applications and not maintaining their databases.
  3. Correct large memory amount handling (we all know that Redis can manage with hundreds of gigabytes of RAM on single machine). It doesn't have problems with Garbage collection like Java.

And finally existence of Java Developer friendly Redis client - Redisson.
Redisson provides many Java friendly objects on top of Redis, like:

  • Set
  • ConcurrentMap
  • List
  • Queue
  • Deque
  • BlockingQueue
  • BlockingDeque
  • ReadWriteLock
  • Semaphore
  • Lock
  • AtomicLong
  • CountDownLatch
  • Publish / Subscribe
  • ExecutorService
  • and many more...

Redisson supports local cache for Map structure which cold give you 45x performance boost for read operations.

Here is the article describing detailed feature comparison of Ehcache and Redis.


You can think Redis as a shared data structure, while Ehcache is a memory block storing serialized data objects. This is the main difference.

Redis as a shared data structure means you can put some predefined data structure (such as String, List, Set etc) in one language and retrieve it in another language. This is useful if your project is multilingual, for example: Java the backend side , and PHP the front side. You can use Redis for a shared cache. But it can only store predefined data structure, you cannot insert any Java objects you want.

If your project is only Java, i.e. not multilingual, Ehcache is a convenient solution.