OckhamsRazor
OckhamsRazor

Reputation: 4906

Why is ehcache faster than memcache?

Directly quoting from ehcache's website [source]:

The idea here is that your caches are set up in a cache hierarchy. Ehcache sits in front and memcacheg behind. Combining the two lets you elegantly work around limitations imposed by Google App Engine. You get the benefits of the speed of Ehcache together with the umlimited size of memcached. Ehcache contains the hooks to easily do this. To update memcached, use a CacheEventListener. To search against memcacheg on a local cache miss, use cache.getWithLoader() together with a CacheLoader for memcacheg.

This seems to imply that using ehcache with memcached would be faster than using memcached alone. Why would ehcache be faster than memcached? The way I see it, both are in memory caches so why the performance difference?

Upvotes: 1

Views: 5702

Answers (1)

gerry.liang
gerry.liang

Reputation: 91

Ehcache often runs in the same jvm process with the application,so it does not need serialization and io costs.

When using Ehcache with memcached,some objects are stored in ehcache heap and others are in memcached. so mix ehcahe and memcached will faster than only use memcached.

Runs ehcache and application in the same JVM process is a way to exchange RAM space for time, but you can not put too many data to ehcache because you need to consider replication between servers.

Upvotes: 1

Related Questions