[Zope] Zope Database Cache

Brian Lloyd brian@zope.com
Fri, 25 Oct 2002 10:39:15 -0400


> I have some questions about the Zope database cache. You can change the
> settings for this cache on the "Cache Parameters"-tab in the database
> management screen (/Control_Panel/Database).
>
> 1. The default target size is 400 objects. But the total number of objects
> in the combined caches is much larger. How does the target size influence
> the total number of objects in the cache? How should this setting be used?
>
> 2. "Total number of objects in all caches". I don't use any
> RamCacheManager. Does this mean that there is more than one database
> cache?

These questions are interrelated - there is a db cache for each
ZODB connection (should be 4 by default "out of the box" for Zope).

So the total for all caches is just the number of object in each
connection cache. This means that in theory, with a target size
of 400, the system will try hard to make sure that no more than
1600 (persistent) objects are sitting around in memory (400 x 4
ZODB connections).

This gives you some way of controlling memory usage, though it is
not very fine-grained. The cache favors commonly used objects, which
depending on your application may be tiny objects or huge objects.

Cache tuning is still an art, not a science :) You need to look at
your application behavior and the kinds of objects in memory (you
can use the debug screen in the Control Panel to do that) and do
some experimentation to find optimum settings.

A well-tuned cache will strike a balance between keeping the objects
that are used most often in the cache and desired memory footprint.
Assuming your application doesn't do things that cause large memory
spikes, this can give you a relatively predictable plateau for the
amount of memory the process will consume.

Hope this helps!

Brian Lloyd        brian@zope.com
V.P. Engineering   540.361.1716
Zope Corporation   http://www.zope.com