Search code examples
javacachingredisehcache

Putting a cache infront of distributed redis cache


I have a java enterprise application that does a lot of fetching of cached data. The data is stored in a 3 server redis cluster and is accessed by 5 backend api nodes.

I am seeing that we are putting alot of stress on the redis caches, which is why I am wondering if it is dumb to put a in-mem cache such as Ehcache in front of redis. With this solution I would set the TTL to be very short in the Ehcache.

Is this a common solution or is it more reasonable to look into expanding the redis cluster?


Solution

  • Thing you are talking about is called near cache. It's absolutely legit solution in some cases. It provides trade-off between performance and freshness of the values. However you can only consider this option if seeing a bit stale values is tolerable in your case. Just FYI, Apache Ignite supports this feature out of the box.