« Clustering JBoss in the Amazon EC2 Cloud | Main | Binding JBoss to a Different set of Ports »

June 17, 2008


TrackBack URL for this entry:

Listed below are links to weblogs that reference EhCache vs Memcached caching for JEE Applications:



Hugo Troche

No? You mean that you don't agree with the results or that I should do more extensive testing?


You should have tried to run either caches on a separate machine, so your app server would access them via tcp/ip.
I believe memcached was so slow in your example because it used serialization and ehcache did not. Serialization is a serious bottle neck, you should consider using externalization instead.

Hugo Troche

Thank you for commenting. You are right, the equation is different when the cache is in a different machine that the application server.

The question then is: in a distributed cache environment, will Memcached be faster?

It could be an interesting test to try it out. On the other hand, the performance of the cache in the case where the cached object is in the same box as the application server will be orders of magnitude better. So, if the application has two servers, 50% of the cache calls should be local. If the application has 3, 33% should be local, etc. That along could be a big performance difference in the system. Also, EhCache does not distribute objects like Memcached and that would have to be taken into account. Again, without actually testing this is just speculation.


This comparison is not really clean. Memcached was designed to increase performance for multi-server enviroment, but not for only one JVM. For sure additional serialisation will produce additinal performance-leak, but...

...it is nothing in comparison with pure( for ex. ) database access. Try to improve your tests with 10000 DB-selects from 2,4,8.. different servers with and without both of caches...

and then pls share your test-resuls! ;)


You are not comparing apple to apple here. EhCache is residing in the same JVM with your app server, memcached is not. I would said that in a distributed test, memcached would beat ehcache. But how to put EhCache in a distributed environment is a myth to me!

memcached is as much a *scaling* solution as it is a performance solution. This is like testing mapreduce using a single box.


As of today, ehcache's JCache page says,

"Ehcache provides a preview implementation of JSR107 via the net.sf.cache.jcache package."

AFAIK it's not yet standardised.


Another thing you don't mention is the GC churn caused by an in-process cache. With a large heap, this can be big performance problem. Use of an out-of-process cache can mitigate this problem.

Sameer Charles

To me this test just does not make any sense, a single box test on a highly scalable distrubuted caching system like memcached? hmm.

In addition I agree with Steve that JCache is not yet final and its "inactive" which means nothing happens there since 1.5 years. This basically means that either the expert committee is not able to agree on the spec or the spec reached a level where it has serious problems.

Personally I like ehCache implementation of JCache but this does not mean that I will just select it for any J2EE application.

sreenath venkataramanappa

What about TreeCache? TreeCache supports transactional caching which neither EHcache nor MemCache supports as of this writing...

Cheap Computers Canada

We get to learn the latest on the innovative technology through blogs.

James Bowman

As already said above, this is not a fair comparison. Whilst EHCache works well as a near cache (Hibernate level 2 cache) and supports the JCache specification, it does not as standard function as a distributed cache (see Coherence, Gigaspaces, Gemfire, Infinispan, etc.). In order to use EHCache as a distributed cache, it must be combined with another product called Terracota.

Account Deleted

All my Caching needs are not always distributed cache. If your system architecture recommends to have a distributed ehcache then we need to compare between ehcache and memchached. Again this depends on type of distributed architecture. If it is a centralised cache is expected, then i would prefer go for memcahced.If it is requirement to replicate caching details between instances (though this is not exactly a disributed option - without any centralized cache), then i would go for ehcache/treecache.

If it is requirement to have a simple caching within a single instance of JVM, then memchached would have been a overhead compared to ehcache.

End of the day, I have never found a single solution in this world that can solve all my needs.

Air Jordan

The worst kind of love is the one when you want someone but you know you can’t have them. Best wishes for you.

coach bags

The blog is nicely done. Attractive written shows its quality. Keep it up in this way. Thanks a lot


This is perfect that people can receive the home loans and this opens completely new chances.

Retro Jordan

I love the comparison you made between the colors! I'm personally looking forward to the Daffodil Delight as I'm a sucker for anything yellow. I wish it was more lemon-y! As for the Marina Blue, that'll be another favorite of mine I think! now link my name to see something about jordan shoes,they are also good and you will like them,come on!

ugg boots outlet

How great minds think alike.

coach outlet

I wish you great blessings and love.*

ugg boots

just go around, but surprised by your blogs, the information is so interesting,I deeply attract by it.

Air Jordans

Be to act , that each tomorrow.

cheap air jordans

I want to bring out the secrets of nature and apply them for the happiness of man . I don't know of any better service to offer for the short time we are in the world .

Kids puzzle

Everyear,when the Christmas coming ,the gifts is neccesery.So i think

wholesale Juicy Handbags

Mulher fina : Muito simpático!
Mulher comum: Que homem liiiindo!
Mulher vulgar : Dessa fruta eu chupava até o caroço!
Mulher deprava : Ah, se eu pego... deixo ele fazer barba, cabelo e bigode.

The comments to this entry are closed.