Andrus,
thanks a lot for the hints.
1. I have designed using Cayenne 3.0 (with MySQL & JSP). I have
converted over from DataContext to BaseContext (as best as I have been
able to follow your usage instructions).
2. Given all the layers of caching (MySQL, Cayenne, Tomcat, etc), my
intuition is lacking with respect to expected behavior.
So my generic approach is to first implement your "best practices" for
my unit testing, then devise an appropriate load test (one that will
simulate about 50-100 concurrent users using JMeter). (Based on your
input I should probably think about using a finer-grained profiler
like YourKit as well)
My problem is that given all of the advanced caching going on, I have
very little idea of what a healthy profile should look like.
Therefore, I am guessing at this point. :)
Conditions:
- Java 1.5, MySQL, JSP, Tomcat
- Cayenne 3.0, BaseContext, MaxObjects=10000, SharedCache,
MaxConnections=10
- 50-100 concurrent user threads
- Tomcat: (two cases) Xms64m & Xms256m, both with SessionTimeOut=5min
- MyDesign: store the large search-result lists in a custom class
store in a session object (which is released on session timeout)
Results:
At Xms64m, the website grinds to a halt at about 50 user threads.
Using Xms256m, there seems to be no issue with degraded performance.
For both max-heap values, after 5 min, most of the memory is released
(i.e. 70MB @max and 20MB after release and GC). There always seems to
be some residual memory used over base line but this appears to be
constant and not growing.
Questions:
1. With this simple test there does not appear to be the
characteristic stair step associated with a memory leak. *If* my
assumptions are correct then I simply need to set Tomcat-Xms to
support the Cayenne caching implementation. Does this sound correct?
2. When I am able to predict the appropriate user needs: I attempt to
nullify all of my search list references and then garbage collect (to
message BaseContext to do any house-cleaning). Is this sufficient
(with the Cayenne 3.0 weak-reference model) or do I need to read more
documentation on "house cleaning" procedures?
3. I have, at best, a peripheral understanding of BaseContext,
especially wrt optimal usage for WebApps. When I use
BaseContext.getThreadObjectContext() to perform a query, will I
generate two separate objects (for the same MySQL data mapping) for
two separate users requesting the same data? I would assume that he
answer and there is a single cache for both user threads and that two
*references* to the cached objects are generated. Am I close, or do I
need to do some more Cayenne homework? :)
Thanks
Joe
On Jun 3, 2009, at 4:10 AM, Andrus Adamchik wrote:
And another one...
Query cache and snapshot cache are all using LRUMaps, so they won't
grow indefinitely even in 2.0, however the total amount of RAM given
to the JVM may not be enough to fill the LRU to the full default
capacity. So either consider reducing the "Size of Object Cache" in
the Modeler, or give your process more memory with -Xmx.
In any event, consider using a profiler to check what causes a
memory leak. This may be faster than guessing. Can't recommend
anything free (there should be some Eclipse plugins??). I am using
YourKit profiler for this purpose.
Andrus
On Jun 3, 2009, at 11:04 AM, Andrus Adamchik wrote:
I've done a fair share of Cayenne-based application performance
testing. Although I don't have a single recipe, it all depends on
the application expected usage patterns.
Just a general Cayenne memory management hint - if you are using
Cayenne version prior to 3.0, watch out for DataContexts filling
with objects. Every single object fetched via a DataContext, will
be cached in it, so it is expected that the user takes care of
disposing of DataContexts in one way or another (putting a
DataContext in a session is a common strategy for doing that, but
depending on your app this may not be enough). So if you are
processing lots of objects within a single DataContext, consider
replacing it manually (3.0 solves this problem by using weak
references).
Andrus
On Jun 2, 2009, at 1:44 AM, Joe Baldwin wrote:
I am attempting to do performance testing on a JSP webapp that
uses Cayenne for all of the database access. I am currently using
Jmeter and JConsole, but the first tests seem to indicate that
there is a memory leak (either that or I am created a bad test).
Does anyone have good experience with a test suite that is
compatible with Cayenne in a Tomcat context?
Thanks,
Joe