jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Rasmussen <rasmus...@2e-systems.com>
Subject Re: JCS Performance test
Date Tue, 05 Jul 2005 16:13:35 GMT
I tried reducing the log level
to WARN and was amazed ! 
It now reads get 3000 objects
from the cache in about 0.6 seconds.

Thanks for pointing it out to me.

Regards
Thomas





On Tue, 2005-07-05 at 07:22 -0700, Aaron Smuts wrote:
> Also, what log level do you have set for JCS?
> 
> Don't try to run with the log level at debug.  Info
> should be fine.  I run at warn in prod. . . 
> 
> 
> 
> --- Thomas Rasmussen <rasmussen@2e-systems.com> wrote:
> 
> > Hi,
> > 
> > like saipradeep I'm new to JCS.
> > 
> > I've read the document on JCS written 
> > by Aaron Asmuts. 
> > Trying to play with the example application
> > from that document (the book store example),
> > I've adopted the code to fit into the needs
> > of the project I'm currently working on.
> > 
> > To test the performance of the application,
> > basically I collect some data from the database,
> > knowing that the cache is empty at this point.
> > 
> > Immediately after that, I query all the objects
> > using exactly
> > the same keys as the database query, and sure enough
> > the application finds them all in the cache.
> > The Ant log file shows that during the first
> > operation
> > there are only "misses" and during the second
> > obviously only hits.
> > 
> > Now, when timing these two actions (getting all
> > the information from the db and after that reading
> > it all from the cache) the cache access is only
> > faster if I create a small number of objects (some
> > 250). 
> > By that point the cache access continues to grow
> > slower
> > than the direct database access.
> > 
> > Raising the available amount of memory, like this:
> > 
> > java -Xms128M -Xmx256M myClass
> > 
> > 
> > didn't affect this unsatisfying behavior in any way.
> > Initially
> > I tried to create about 8600 objects (small objects
> > having only 5 fields containing information about
> > airports) which I subsequently accessed directly
> > from 
> > the cache. Constructing the objects was no problem,
> > but
> > reading from the cache was extremely slow and after
> > some 
> > 20 min, I broke off this action, having "read" only
> > about 2000
> > objects ! (my workstation is a dell 1.8 Ghz computer
> > with 512 MB RAM)
> > 
> > 
> > My cache.ccf file looks like this:
> > 
> > # DEFAULT CACHE REGION
> > 
> > jcs.default=DC
> >
> 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.elementattributes=org.apache.jcs.engine.ElementAttributes
> > jcs.default.elementattributes.IsEternal=false
> >
> jcs.default.cacheattributes.maxMemoryIdleTimeSeconds=3600
> > jcs.default.elementattributes.maxLifeSeconds=3600
> > jcs.default.elementattributes.IdleTime=1800
> > jcs.default.elementattributes.IsSpool=true
> > jcs.default.elementattributes.IsLateral=false
> > jcs.default.elementattributes.IsRemote=false
> > 
> > 
> > 
> > # PREDEFINED CACHE REGIONSInicially
> > 
> > jcs.region.testCache1=DC
> >
> jcs.region.testCache1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
> >
> jcs.region.testCache1.cacheattributes.MaxObjects=10000
> >
> jcs.region.testCache1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
> >
> jcs.region.testCache1.cacheattributes.maxMemoryIdleTimeSeconds=7200
> >
> jcs.region.testCache1.elementattributes=org.apache.jcs.engine.ElementAttributes
> >
> jcs.region.testCache1.elementattributes.IdleTime=1800
> >
> jcs.region.testCache1.elementattributes.IsEternal=false
> > jcs.region.testCache1.elementattributes.IsSpool=true
> >
> jcs.region.testCache1.elementattributes.IsLateral=false
> >
> jcs.region.testCache1.elementattributes.IsRemote=false
> > 
> > 
> > 
> > #### AVAILABLE AUXILIARY CACHES
> > 
> >
> jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
> >
> jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
> > jcs.auxiliary.DC.attributes.DiskPath=/tmp/jcs/raf
> > jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000
> > jcs.auxiliary.DC.attributes.MaxKeySize=10000
> >
> jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000
> > jcs.auxiliary.DC.attributes.MaxRecycleBinSize=7500
> > 
> > 
> > 
> > The main class is, though adapted, pretty much kept
> > as the example
> > code by Aaron Asmuts (I apologize for the 
> > bad format of the code that might be caused by my
> > email client):
> > 
> > 
> > public class AirportObjManager {
> > 	
> > 	private static AirportObjManager instance;
> > 	private static int checkedOut = 0;
> > 	private static JCS airportCache;
> > 	private DatabaseManager db;
> > 		
> > 	
> > 	private AirportObjManager() {
> > 		
> > 		try {			
> > 			airportCache = JCS.getInstance("testCache1");
> > 		}		
> > 		catch (Exception e) {
> > 			System.out.println("Error trying to initialize
> > 			the cache region.");
> > 			e.printStackTrace();
> > 		}
> > 	}
> > 	
> > 	
> > 	/* Accesspoint */	
> > 	public static AirportObjManager getInstance() {
> > 				
> > 		synchronized (AirportObjManager.class) {
> > 			if (instance == null) {			
> > 				instance = new AirportObjManager();
> > 			}	
> > 		}
> > 		
> > 		synchronized (instance) {
> > 			checkedOut++;
> > 		}
> > 		
> > 		return instance;
> > 	}
> > 	
> > 	
> > /**
> > * @param airportCode
> > * @return AirportObj
> > */
> > public AirportObj getAirportObj(String airportCode)
> > {
> > 	
> > 	return getAirportObj(airportCode, true);	
> > }
> > 	
> > 
> > /**
> >  * @param airportCode
> >  * @param fromCache
> >  * @return AirportObj
> >  */
> > public AirportObj getAirportObj(String airportCode,
> > boolean fromCache) {
> > 	
> > 	AirportObj airObj = null;
> > 		
> > 	if (fromCache) {
> >            airObj = (AirportObj)
> > airportCache.get(airportCode);
> > 	}
> > 		
> > 	if (airObj == null) {
> > 		//System.out.println("Says the getAirportObj
> > Method:
> > 		Object"
> > 		+ airportCode + " not in cache, fetching from
> > 		database.");
> > 
> > 	airObj = (AirportObj) loadAirportObj (airportCode);
> > 	}
> > 		return airObj;
> > 	}
> > 	
> > 	
> > 	/** 
> > 	 * loads the airport from the database 
> > 	 *  and creates an object from it
> > 	 *  
> > 	 * @param aCode
> > 	 * @return AirportObj
> > 	 */
> > 	public AirportObj loadAirportObj(String aCode) {
> > 		
> > 		AirportObj airport_object = new AirportObj();
> > 		boolean found = false;
> > 		
> > 		// Here I fetch the data from the db and
> > initialize
> > 		// the fields of the object with the values
> > 	        		}
> > 
> === message truncated ===
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jcs-users-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org


Mime
View raw message