Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis or Ehcache?

Which is better suited for the following environment:

  1. Persistence not a compulsion.
  2. Multiple servers (with Ehcache some cache sync must be required).
  3. Infrequent writes and frequent reads.
  4. Relatively small database (very less memory requirement).

I will pour out what's in my head currently. I may be wrong about these.

I know Redis requires a separate server (?) and Ehcache provides local cache so it must be faster but will replicate cache across servers (?). Updating all caches after some update on one is possible with Ehcache.

My question is which will suit better for the environment I mentioned?
Whose performance will be better or what are scenarios when one may outperform another?

Thanks in advance.

like image 653
Sachin Sharma Avatar asked Oct 14 '15 11:10

Sachin Sharma


People also ask

What is better than Redis?

Memcached, MongoDB, RabbitMQ, Hazelcast, and Cassandra are the most popular alternatives and competitors to Redis.

Is Ehcache good?

EhCache is a widely used, pure Java cache that can be easily integrated with most popular Java frameworks, such as Spring and Hibernate. It is often considered to be the most convenient choice for Java applications since it can be integrated into projects easily.

Should I use Memcache or Redis?

Redis uses a single core and shows better performance than Memcached in storing small datasets when measured in terms of cores. Memcached implements a multi-threaded architecture by utilizing multiple cores. Therefore, for storing larger datasets, Memcached can perform better than Redis.

Is Ehcache in-memory cache?

1. Overview. In this article, we will introduce Ehcache, a widely used, open-source Java-based cache. It features memory and disk stores, listeners, cache loaders, RESTful and SOAP APIs and other very useful features.


1 Answers

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.

like image 138
smallufo Avatar answered Sep 16 '22 22:09

smallufo