PDA

View Full Version : Which is better to use - EHCache, OSCache or Swarmcache


2devnull
Sep 26th, 2004, 12:07 AM
I have some relatively large XML documents that I would like to cache for a period of time. I already cache the query from the DB using OSCache with Ibatis SQL Maps. I would like to know you opinion of caching the XML document that is then create from this data. Would you suggest using EHCache, OSCache or SwarmCache? Why?

If you have done this analysis before, please share any performace results you may have. Thank you.

Savagearts
Sep 28th, 2004, 03:42 AM
I think JBoss Cache is better . JBoss cache is a fully transactional, cluster-safe caching system.

irbouho
Sep 28th, 2004, 08:26 PM
Take a look at Table 14.1. Cache Providers (http://www.hibernate.org/hib_docs/reference/en/html/performance.html#performance-cache), it summarize some of the differences between these cache providers.

2devnull
Sep 28th, 2004, 08:41 PM
Funny thing, I was reading 'Hibernate in Action' this weekend and saw the comparison in the book. Thanks though.

I decided to go with Ehcache and re-used Ben's code and bean set up for what was done in Acegi. I wanted to use OSCache but the documentation is very weak.

irbouho
Sep 28th, 2004, 08:54 PM
Great choice ;)

Spring Framework 1.1.1 allows for configuring EHCache using IOC. Take a look at package org.springframework.cache.ehcache (in cvs) for more details.

Ben Alex
Sep 30th, 2004, 06:35 AM
If I were starting a new project, I'd use Spring's new org.springframework.cache.ehcache package. Acegi Security will be depreciating its implementations in favour for this package once it's in a Spring core release.

2devnull
Sep 30th, 2004, 07:33 AM
If I were starting a new project, I'd use Spring's new org.springframework.cache.ehcache package. Acegi Security will be depreciating its implementations in favour for this package once it's in a Spring core release.


Thanks Ben. I took irboubo advise and got the package you metioned from CVS. I also updated my AGEGI provider to use it. Work fine so far.

<!-- ################################################## ### -->
<!-- ################## Ehcache setup #################### -->
<!-- ################################################## ### -->

<bean name="mwEhcacheMgr" class="org.springframework.cache.ehcache.EhCacheManagerFa ctoryBean">
<property name="configLocation">
<value>/WEB-INF/ehcache.xml</value>
</property>
</bean>

<bean name="WBSCacheFB" class="org.springframework.cache.ehcache.EhCacheFactoryBe an">
<property name="cacheManager">
<ref bean="mwEhcacheMgr" />
</property>
<property name="cacheName">
<value>WBSCache</value>
</property>
</bean>

<bean name="UserCacheFB" class="org.springframework.cache.ehcache.EhCacheFactoryBe an">
<property name="cacheManager">
<ref bean="mwEhcacheMgr" />
</property>
<property name="cacheName">
<value>UserCache</value>
</property>
</bean>

<bean id="userCache" class="com.method.util.EhCacheBasedUserCache">
<property name="cache">
<ref bean="UserCacheFB" />
</property>
</bean>

<bean id="wbsCache" class="com.method.util.WBSCache">
<property name="cache">
<ref bean="WBSCacheFB" />
</property>
</bean>


<bean id="mwAuthenticationProvider" class="com.method.security.MWAuthenticationProvider">
<property name="userCache">
<ref bean="userCache" />
</property>
<property name="authenticationDao">
<ref bean="methodDao" />
</property>
</bean>

<bean id="showWBSController" class="com.method.web.browse.xslt.ShowWBSController">
<property name="methodNameResolver">
<ref local="showWBSControllerResolver" />
</property>
<property name="methodDBFacade">
<ref bean="methodDBFacade" />
</property>
<property name="pathMapping">
<ref local="pathMapping" />
</property>
<property name="wbsCache">
<ref bean="wbsCache" />
</property>
</bean>

ehcache.xml

<cache name="WBSCache"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="124416000"
timeToLiveSeconds="124416000"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
/>


<cache name="UserCache"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="300"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
/>

jagarciaga
Jun 8th, 2005, 04:12 PM
A newbie question. Is com.method.util.EhCacheBasedUserCache a class of your own? How does it look like?

asmuts
Feb 17th, 2006, 08:02 PM
I'm working a basic comparison of EHCache and JCS. The JCS disk store is much more sophisticated and the JCS LRU Memory cache appears to be twice as fast as EHCache.

http://jakarta.apache.org/jcs/JCSvsEHCache.html

gmatthews
Feb 19th, 2006, 04:33 PM
I think JBoss Cache is better

+1

If you're building a system that can run on one box, by all means use the other caches, but if you have 2 or more servers then your only practical choice is JBoss TreeCache.

asmuts
Feb 19th, 2006, 09:49 PM
We discussed some of the drawbacks and benefits of the JBoss caching option son the JCS user list last year:

http://mail-archives.apache.org/mod_mbox/jakarta-jcs-users/200503.mbox/browser

gmatthews
Feb 20th, 2006, 04:45 PM
There's also a new supa dupa version of JBoss Cache coming out shortly.

See http://www.jboss.com/wiki/Wiki.jsp?page=JBossCache

asmuts
Feb 20th, 2006, 05:02 PM
What specifically makes JBoss cache better? Is it easier to use, more scallable, more feature rich, or faster than other caches such as JCS? The answer to all of the above seems to be no.

I don't want transactional distribution. It simply cannot scale given current harware, especially via JGroups.

I don't want the AOP logic, since it solves an uncommon problem (where you change only a small bit of a large object but have to send the entire thing over the wire) at the cost of added complexity and a performance penalty for the common case where you want the entire object to go over the wire.

It's too tied to JBoss and I would never sell my soul to any container.

It isn't as fast as JCS.

It ins't plugable like JCS.

There may be some cool disk cache features that come with the JBoss cache, but I've never looked into how well they perform.

asmuts
Feb 20th, 2006, 05:06 PM
The JCS site has been updated with a getting started guide, an faq, and several other new documents:
http://jakarta.apache.org/jcs/index.html

gmatthews
Feb 21st, 2006, 01:42 AM
What specifically makes JBoss cache better?

I wasn't so much pointing out which one is better.

I was pointing out that if you need to run two boxes, you choices are:
1. JBoss Cache, or
2. JBoss Cache, or
3. ...you get the idea...

You probably pointed out several aspects of caching that should be considered, but you've got to get past the "are you running 2 or more boxes?" question first before they're even relevant.

Also, last time I looked swarmcache wasn't transactional, which counts it out if the data in your system has any sort of value and/or the customers of your system are likely to get pissed off if problems occur relating to non-transactional caching. Given JBoss Cache as an alternative, that pretty much counts it out of the list.

asmuts
Feb 21st, 2006, 12:19 PM
I guess I didn't make myself clear. JCS is a distributed caching system. I'm using it to distribute data across clusters of various sizes. I pointed out why I do not want a transactional distribution mechanism. . . .

Take a look at the documentation:

http://jakarta.apache.org/jcs/index.html

gmatthews
Feb 21st, 2006, 05:03 PM
asmuts, I see now you're a developer on JCS. That explains your post.

I also assumed from the poster's original question that they want a cache that plugs into Hibernate, given their mention of all of the Hibernate caches (except JBoss cache).

Maybe you can clarify if JCS plugs into Hibernate, or if there are future plans to allow it to be used as a 2nd level cache for Hibernate.

btw, the following is just plain wrong. JBoss Cache isn't tied to the JBoss app server. You can use JBoss Cache as a standalone plug in to Hibernate.

It's [JBoss Cache] too tied to JBoss and I would never sell my soul to any container.

asmuts
Feb 21st, 2006, 09:15 PM
That I started JCS is irrelevant to whether or not JCS is better than JBoss cache. I asked for reasons to think that JBoss cache is better. Accusing me of bias is not a reason to think that JBoss is better. Perhaps this might help:

http://en.wikipedia.org/wiki/Ad_hominem

Can you offer any reasons why JBoss is better? What makes it better? Can you address the fundamental design flaws that I pointed out? I never said that you must use it inside of JBoss. . . .

gmatthews
Feb 22nd, 2006, 05:24 PM
Can you offer any reasons why JBoss is better?

I'll try. Firstly, my requirements and goals are to operate a production system on commodity hardware, and safeguard data that is extremely valuable to our customers.

We also can't handle the system load on one box, so operate multiple boxes behind an Apache front end.

So, I've decided we need transactional clustering to deliver the above requirements.

The only choice seems to be JBoss TreeCache, which works pretty well.

I think the next JBoss TreeCache release supports eviction from the cluster as opposed to replication across the cluster which will be good.

I'm hoping it will scale reasonably well since we're scheduled to do a country wide sales and marketing rollout around April so will likely have some interesting performance figures to share by then.

Regards,

thejavafreak
Dec 20th, 2006, 10:52 PM
Great choice ;)

Spring Framework 1.1.1 allows for configuring EHCache using IOC. Take a look at package org.springframework.cache.ehcache (in cvs) for more details.

OSCache also support integration with spring (http://opensource.atlassian.com/confluence/spring/display/INTEGRATE/OSCache).

twoencore
Jan 1st, 2007, 03:19 PM
I had alot of success with using OSCache on a previous project, the documentation was good.. an advantage i saw over EHCache was OSCache ability to return stale content while the cache is being updated... EHCache has a limitation that blocked thread writes while being updated..which made a bottle neck when doing "Method level" caching...with OSCache would send back the stale content while the cache is being updated from another thread.

OSCache also supports distributed cache clustering via JMS.


also your not tied to a container(JBossTree) :)

tgautier
Mar 11th, 2008, 05:16 PM
I'll try. Firstly, my requirements and goals are to operate a production system on commodity hardware, and safeguard data that is extremely valuable to our customers.

We also can't handle the system load on one box, so operate multiple boxes behind an Apache front end.

So, I've decided we need transactional clustering to deliver the above requirements.

The only choice seems to be JBoss TreeCache, which works pretty well.

I think the next JBoss TreeCache release supports eviction from the cluster as opposed to replication across the cluster which will be good.

I'm hoping it will scale reasonably well since we're scheduled to do a country wide sales and marketing rollout around April so will likely have some interesting performance figures to share by then.

Regards,

Sorry to resurrect this thread from the dead - but I am quite curious after two years how things turned out. Did you end up using transactions w/TreeCache? Did it scale for you? How has it been in operation?

Thanks,

Taylor Gautier
Product Manager, Terracotta