Home


2.10 Impact of memory cache on JVM garbage collection

For large Web sites that cache many thousands of items, the cache designer needs to be aware of the potential impact these objects can have on JVM memory utilization. Implementing DynaCache without proper consideration can lead to a large increase in memory resource consumption and therefore cause serious side effects.

Some of the symptoms you may observe are OutOfMemory exceptions due to heap fragmentation type problems. One of the root causes of this problem is configurations that result in greater numbers of DynaCache objects accumulating in the JVM heap than can be handled by existing resources.

For example, if the average page size is 50 KB and you set the in-memory cache pool size to 10,000 objects, you end up needing 500,000 KB (half a gigabyte) of JVM heap to accommodate the cache. DynaCache does not compress its cache entries.

If the maximum heap size is set to one gigabyte, then this represents a significant amount of the heap being allocated to DynaCache. It also means that the rest of your application must operate within the remaining 500,000 KB of heap space, which may not be what you intended.

In an effort to try to prevent some of these fragmentation issues, DynaCache will reuse cached item memory objects via a technique called object pooling. Nonetheless, incorrect caching and invalidation strategies eventually lead to increased memory fragmentation and poorer garbage collection performance.

Some of the possible solutions are...

Applying iFixes related to diskoffload, replication (DRS), and external cache management memory utilization might need to be done to your system depending on its version.

Changing replication policy to Push & Pull from the Push usage pattern might need to be done. (The appropriate DRS replication policy is a difficult issue. Push & Pull will actually end up using more memory, and is discussed at length in Clustering DynaCache).

Applying a JDK™ upgrade to allow tuning of class block clusters.

Creating additional JVMs to spread the load.

We now discuss the tuning of the Java heap and review some of the options available to you to assist with your DynaCache design. Refer to Figure | -19, which illustrates the runtime layout of JVM memory segments, as you read through the next few topics.

Figure 2-19 JVM memory segments

+

Search Tips   |   Advanced Search