Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shared cache between Tomcat web apps

I'm looking for a solution to share a cache between two tomcat web apps running on different hosts. The cache is being used for data synchronization, so the cache must be guaranteed to be up-to-date at all times between the two tomcat instances. (Sorry, I'm not 100% sure if the correct terminology for this requirement is "consistency" or something more specific like having ACID property). Another requirement is of course is that it should be fast to access the cache, with about equal numbers of writes as reads. I do have access to a shared filesystem so that is a consideration.

I've looked at something like ehcache but in order to get a shared cache between the webapps I would either need to implement on top of a Terracotta environment or using the new ehcache cache server. The former (Terracotta) seems like overkill for this, while the cache web server seems like it wouldn't provide the fast performance that I want.

Another solution I've looked at is building something simple on top of a fast key-value store like Redis or memcachedb. Redis is in-memory but can easily be configured to be a centralized cache, while memcachedb is a disk-based persistent cache which could work because I have a shared filesystem.

I'm looking for suggestions on how to best solve this problem. The solution needs to be a relatively mature technology as it will be used in a production environment.

Thanks in advance!

like image 568
cambo Avatar asked Apr 19 '11 04:04

cambo


People also ask

Does Tomcat have a cache?

Apache Tomcat has built-in caching features that cause custom modifications to .

How do I see Tomcat cache?

First, open the Central Configuration Manager and stop Tomcat with the help of stop icon. Now please go to the Default Tomcat cache Directory: <Default BI Install Directory>Tomcat6workCatalina. Now you have to rename the localhost directory to localhost_old and then Restart Tomcat.

Can we delete work folder in Tomcat?

You can certainly clear it's contents, but I wouldn't remove the directories themselves. Odds are Tomcat will re-create them when you restart it (or worst, it'll crash, but I doubt that).


1 Answers

I'm quite sure that you don't require terracotta or ehcache server if you need a distributed cache. Ehcache with one of the four replication mechanisms would do.

However, based on what you've written I guess that you're looking for more than just a cache. Memcached/Ehcache are examples of what you might call a caching layer for your application - nothing more.

If you find yourself using words like 'guaranteed' 'up-to-date' 'ACID' you're better off using an in-memory DB like Oracle Times Ten/MySQL Cluster/Redis with a disk-based persistent storage.

like image 112
Ryan Fernandes Avatar answered Sep 19 '22 16:09

Ryan Fernandes