jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niall Gallagher <ni...@switchfire.com>
Subject Re: Re: JCS data retrieval is slower than database!!
Date Fri, 16 May 2008 12:12:39 GMT
Hi Debasis,

Yes the memory cache is very fast. Basically the way JCS behaves for us
is that when we request data and it's located only on (say) the remote
cache server, JCS fetches it automatically and copies it into local ram.
Then next time we request it JCS returns it very quickly. We didn't need
to configure this behaviour explicitly. We just found that when using
the remote server, JCS copies data to local ram automatically,
presumably for this reason (to speed things up).

I'd imaging that the lateral and disk caches would behave in a similar
way and keep a copy of data in ram when accessed to speed retrievals up.
You'll probably want to configure it such that a certain number of most
recently (or frequently) used objects stay in local ram, but if they're
not used then they are spooled out to disk. If they are subsequently
needed again JCS can copy them back into ram (and spool out something
else if necessary). I know JCS supports spooling like this but I've not
used the disk cache.

Also remember if you're testing retrieval speed that you should retrieve
the same data number of times in your test, because the first retrieval
might indeed be slow (due to remote/disk fetching) but subsequent
retrievals should (if properly configured) be very fast.

We store all static data in one region. For each type of static data we
load all objects into a collection, and then put the collection in the
StaticDataRegion as a single element.

We store transient data objects of particular types directly in
TransientDataRegionX, such that objects of the same type are stored in a
region of their own, a unique key per object. We prefer to store
transient data in the cache for a maximum fixed period of time (1 hour),
such that it gets reloaded periodically if something got out of sync.

Our cache.ccf file is quite simple:
-----------------------------------------------
#
# Default settings, specifying a local in-memory cache of max size 0
objects
# to effectively prevent objects being stored in regions which are not
configured explicitly.
#
# These settings will be inherited by any regions which do not provide
their own settings
# to override these settings, thus unconfigured regions will not store
any objects.
#
jcs.default=
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.IsLateral=false
jcs.default.elementattributes.IsRemote=false
jcs.default.elementattributes.IsSpool=false

#
# Settings configuring an auxiliary cache located on a remote caching
server.
# (auxiliary as in addition to the built-in local memory cache)
#
jcs.auxiliary.remotecache=org.apache.jcs.auxiliary.remote.RemoteCacheFactory
jcs.auxiliary.remotecache.attributes=org.apache.jcs.auxiliary.remote.RemoteCacheAttributes
jcs.auxiliary.remotecache.attributes.FailoverServers=<ip removed>:1102
jcs.auxiliary.remotecache.attributes.GetOnly=false
jcs.auxiliary.remotecache.attributes.Receive=true
jcs.auxiliary.remotecache.attributes.RemoveUponRemotePut=true
jcs.auxiliary.remotecache.attributes.RmiSocketFactoryTimeoutMillis=15000


#
# Settings specifying a cache region of unlimited size on a remote cache
server,
# where objects stay in remote server memory permanently and are never
evicted.
#
# Note that being a region on a remote cache server, the configuration
file on the remote server will
# actually take effect, but duplicating the same settings client-side is
recommended. See JavaDoc
# note on this in class JCSCacheConfigurationFileTemplate.
#
jcs.region.StaticDataRegion=remotecache
jcs.region.StaticDataRegion.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.StaticDataRegion.cacheattributes.MaxObjects=2147483647
jcs.region.StaticDataRegion.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.StaticDataRegion.cacheattributes.UseMemoryShrinker=false
jcs.region.StaticDataRegion.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.region.StaticDataRegion.elementattributes.MaxLifeSeconds=-1
jcs.region.StaticDataRegion.elementattributes.IsEternal=true
jcs.region.StaticDataRegion.elementattributes.IsLateral=false
jcs.region.StaticDataRegion.elementattributes.IsRemote=true
jcs.region.StaticDataRegion.elementattributes.IsSpool=false

#
# Settings specifying a cache region of max size 10,000 objects on a
remote cache server,
# where objects stay in the remote server's memory for up to 60 minutes
(3600 seconds), and the eviction
# thread runs every 5 minutes.
#
# Note that being a region on a remote cache server, the configuration
file on the remote server will
# actually take effect, but duplicating the same settings client-side is
recommended. See JavaDoc
# note on this in class JCSCacheConfigurationFileTemplate.
#
jcs.region.TransientDataRegion1=remotecache
jcs.region.TransientDataRegion1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.TransientDataRegion1.cacheattributes.MaxObjects=10000
jcs.region.TransientDataRegion1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.TransientDataRegion1.cacheattributes.UseMemoryShrinker=true
jcs.region.TransientDataRegion1.cacheattributes.ShrinkerIntervalSeconds=300
jcs.region.TransientDataRegion1.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.region.TransientDataRegion1.elementattributes.MaxLifeSeconds=3600
jcs.region.TransientDataRegion1.elementattributes.IsEternal=false
jcs.region.TransientDataRegion1.elementattributes.IsLateral=false
jcs.region.TransientDataRegion1.elementattributes.IsRemote=true
jcs.region.TransientDataRegion1.elementattributes.IsSpool=false

#
# Settings specifying a cache region of max size 10,000 objects on a
remote cache server,
# where objects stay in the remote server's memory for up to 60 minutes
(3600 seconds), and the eviction
# thread runs every 5 minutes.
#
# Note that being a region on a remote cache server, the configuration
file on the remote server will
# actually take effect, but duplicating the same settings client-side is
recommended. See JavaDoc
# note on this in class JCSCacheConfigurationFileTemplate.
#
jcs.region.TransientDataRegion2=remotecache
jcs.region.TransientDataRegion2.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.TransientDataRegion2.cacheattributes.MaxObjects=10000
jcs.region.TransientDataRegion2.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.TransientDataRegion2.cacheattributes.UseMemoryShrinker=true
jcs.region.TransientDataRegion2.cacheattributes.ShrinkerIntervalSeconds=300
jcs.region.TransientDataRegion2.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.region.TransientDataRegion2.elementattributes.MaxLifeSeconds=3600
jcs.region.TransientDataRegion2.elementattributes.IsEternal=false
jcs.region.TransientDataRegion2.elementattributes.IsLateral=false
jcs.region.TransientDataRegion2.elementattributes.IsRemote=true
jcs.region.TransientDataRegion2.elementattributes.IsSpool=false

(and so on for other transient regions we want to set up)
-----------------------------------------------


Our remote cache.ccf is also quite simple:
-----------------------------------------------
registry.port=1102
remote.cache.service.port=1103

#
# Settings specifying a cache region of max size 10,000 objects on a
remote cache server,
# where objects stay in the remote server's memory for up to 60 minutes
(3600 seconds), and the eviction
# thread runs every 5 minutes.
#
# Note that being a region on a remote cache server, the configuration
file on the remote server will
# actually take effect, but duplicating the same settings client-side is
recommended. See JavaDoc
# note on this in class JCSCacheConfigurationFileTemplate.
#
jcs.default=
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=10000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.ShrinkerIntervalSeconds=300
jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.default.elementattributes.MaxLifeSeconds=3600
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.IsLateral=false
jcs.default.elementattributes.IsRemote=false
jcs.default.elementattributes.IsSpool=false

#
# Settings specifying a cache region of unlimited size on a remote cache
server,
# where objects stay in remote server memory permanently and are never
evicted.
#
# Note that being a region on a remote cache server, the configuration
file on the remote server will
# actually take effect, but duplicating the same settings client-side is
recommended. See JavaDoc
# note on this in class JCSCacheConfigurationFileTemplate.
#
jcs.region.StaticDataRegion=
jcs.region.StaticDataRegion.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.StaticDataRegion.cacheattributes.MaxObjects=2147483647
jcs.region.StaticDataRegion.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.StaticDataRegion.cacheattributes.UseMemoryShrinker=false
jcs.region.StaticDataRegion.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.region.StaticDataRegion.elementattributes.MaxLifeSeconds=-1
jcs.region.StaticDataRegion.elementattributes.IsEternal=true
jcs.region.StaticDataRegion.elementattributes.IsLateral=false
jcs.region.StaticDataRegion.elementattributes.IsRemote=false
jcs.region.StaticDataRegion.elementattributes.IsSpool=false
-----------------------------------------------

Kind regards,

Niall

On Thu, 2008-05-15 at 13:03 -0700, Debasis Bhattacharyya wrote:

> Hi,
>    
>   Thanks for the response. It was interesting.
>   I got two points: 
>   First, memory cache is fast.
>   second: Lateral and disk cache can be slow depending upon usage of  cached objects.
>    
>   So, how to turn my program to use only memory cache? Should I make the first few lines
in the config file look like this and leave the rest unchanged?
>    
>   jcs.default.cacheattributes=
>     org.apache.jcs.engine.CompositeCacheAttributes
> jcs.default.cacheattributes.MaxObjects=1000
> jcs.default.cacheattributes.MemoryCacheName=
>     org.apache.jcs.engine.memory.lru.LRUMemoryCache
>    
>   Is that all I need to do? You know, I tried this and it is as slow as it was..
>   Another question regarding disk cache. I have given local path in the config file and
was assuming it would put something in that folder after cache is oversized/ over it's given
time. But it never put anything?? I think I am missing something.. I read the intro in apache
website. It's very brief. Is ther any other source in the net?
>    
>   Thanks again.
> 
>        

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message