Question

I've been doing some logging of object creation times in our open account process in production. Periodically, initializing an object would take way longer than expected. By initializing I mean calling it's init() and passing a couple of arguments that may be simple variables or objects. e.g.

<cfset validateObj = createObject("component", "compExample").init( 
        productionMode = VARIABLES.productionMode, 
        ipWhiteListed = isWhiteListed, 
        ipLocatorObj = VARIABLES.ipLocatorObj ) />

Thats all that happens in init() methods. Generally the execution time would be 0ms, but at random times I might get 3 or 3.5 seconds. This is not specific to one particular server or to our generally busy period. It appears to be quite random.

One thought was that these templates were being evicted from our template cache as they are not especially frequently used, although I checked cfstat on a number of servers and the max CP/Sec is -1.

Running CF 8,0,1

Has anybody else ever come across this?

Was it helpful?

Solution 3

Increased the max number of items in the template cache. As the cache uses LRU and these objects are specific to functionality that is not particularly frequently used they were getting evicted from the cache. Updated half the servers and kept half the same and compared after the weekend. There was a dramatic reduction in object instantiation times on the servers where the cache was increased.

OTHER TIPS

There may be something within that init method calling something else that could cause the random slow performance. This may be due to how the arguments are being stored within the CFC by the init method.

Inside the CFC init method, is it just:

<cfset variables.productionMode = arguments.productionMode />

Or using a setter method such as:

<cfset setProductionMode(arguments.productionMode) />

Perhaps a structAppend?

<cfset structAppend(variables, arguments) />

The first method, just a straight-up set would be least likely to cause any issues. The second method, using a setter method, could slow things down depending on what that setter method is doing, what other methods it may be calling, etc... The third method should be fairly consistent but I have seen structAppend and other internal functions randomly slow down for no apparent reason.

I think John Whish's comments are definitely something to look into. As well, is there any odd amount of traffic occurred on this server when the init method slows down?

Have you tried isolating just the createObject() call to see if it is the object instantiation resulting in the slow-down or if it truly is the init method? Generally in CF object instantiation can be a randomly slow process. This may be better in CF 8 lately but experience says it could be the problem.

always upgrade the jvm to the latest version and then see if the problem still exists.

Any chance you are running the profiler from the server manager? This has caused us similar random slowness.

Couple of thoughts.... Is there any locking going on or dependencies on a network/webservice/database. Do you have have any auditing or similar going on (for example AOP)?

Also what CF version are you on? Are the servers running the .1 updates (if applicable, i.e. 8.01).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top