0

主要问题是ehcahce 2.6.2 是否会根据 ehcache 配置驱逐过期元素?还是我必须以编程方式驱逐?

在阅读了文档的各个部分(数据寿命缓存大小)之后,我们将当前配置设置为使用 TTI/TTL 和 CacheManager 级别 maxBytesLocalHeap=1024m。设置后,我希望 ehcache 最多只能使用 1Gb 的堆空间进行缓存,但从测试(和生产)中我们始终看到 JVM 堆已满(在我们的例子中为 2GB)

Ehcache 似乎不支持我们设置的 maxBytesLcoalHeap 设置。当然,除非我(很可能)不明白这个设置实际上在做什么。

我们管理员的一些注释:

在此测试期间,maxBytesLocalHeap 值为 1024m,它应该具有有限的缓存条目,并且对整个缓存管理池的总引用为 1GB。8 个单独的缓存被配置为使用 1024m 的一部分。堆利用率稳步攀升至最大堆大小 2GB。一旦到达那里,垃圾收集就会花费更长的时间并且响应时间会降低。测试结束后最大堆大小没有减少。事实上,在测试结束后大约 30 小时,我通过 CacheManagement 页面清除了所有缓存条目,并让 JVM 整夜安顿下来,堆仍然承诺为 2GB。老一代空间的使用是平的,没有多余的空间。在我清除缓存条目后,年轻代空间的使用下降了一些,

感谢您的帮助和指导!

更新

ehcahce 配置

<?xml version="1.0" encoding="UTF-8"?>
<ehcache>

 <cache name="storeCache" 
   maxElementsInMemory="2500"
   memoryStoreEvictionPolicy="LFU"
   eternal="false"
   timeToLiveSeconds="86400"
   statistics="true"> 
   <persistence strategy="none" />
</cache>

<cache name="courseCache" 
   maxElementsInMemory="100000"
   memoryStoreEvictionPolicy="LFU"
   eternal="false"
   timeToLiveSeconds="43200"
   statistics="true"> 
   <persistence strategy="none" />
</cache>

<cache name="mtcIdCache" 
   maxElementsInMemory="500000"
   memoryStoreEvictionPolicy="LFU"
   eternal="false"
   timeToLiveSeconds="3600"
   statistics="true"> 
   <persistence strategy="none" />
</cache>

<cache name="catentryCache" 
   maxElementsInMemory="500000"
   memoryStoreEvictionPolicy="LFU"
   eternal="false"
   timeToLiveSeconds="3600"
   statistics="true"> 
   <persistence strategy="none" />
</cache>

<cache name="priceCache" 
   maxElementsInMemory="500000"
   memoryStoreEvictionPolicy="LFU"
   eternal="false"
   timeToLiveSeconds="300"
   statistics="true"> 
   <persistence strategy="none" />
</cache>

<cache name="inventoryCache" 
   maxElementsInMemory="500000"
   memoryStoreEvictionPolicy="LFU"
   eternal="false"
   timeToLiveSeconds="300"
   statistics="true"> 
   <persistence strategy="none" />
</cache>

<cache name="attributeCache" 
   maxElementsInMemory="500000"
   memoryStoreEvictionPolicy="LFU"
   eternal="false"
   timeToLiveSeconds="300"
   statistics="true"> 
   <persistence strategy="none" />
</cache>

<cache name="partnerCache" 
   maxElementsInMemory="10000"
   memoryStoreEvictionPolicy="LFU"
   eternal="false"
   timeToLiveSeconds="86400"
   statistics="true"> 
   <persistence strategy="none" />
</cache>
</ehcache>

**第二次更新**

这就是我们的管理员所说的堆利用率

我为 websvc01 JVM 拍摄了两个与此耐久性测试相关的内存快照。它们在 dynaTrace 中可用,时间为星期一 09/09 @ 10:10:59 和星期二 09/10 @ 10:46:48。两个快照都是深度内存泄漏分析快照,捕获了字符串对象的值。

在此测试期间,maxBytesLocalHeap 值为 1024m,它应该具有有限的缓存条目,并且对整个缓存管理池的总引用为 1GB。8 个单独的缓存被配置为使用 1024m 的一部分。堆利用率稳步攀升至最大堆大小 2GB。一旦到达那里,垃圾收集就会花费更长的时间并且响应时间会降低。测试结束后最大堆大小没有减少。事实上,在测试结束后大约 30 小时,我通过 CacheManagement 页面清除了所有缓存条目,并让 JVM 整夜安顿下来,堆仍然承诺为 2GB。老一代空间的使用是平的,没有多余的空间。在我清除缓存条目后,年轻代空间的使用下降了一些,

更新:

感谢您的回复,我非常感谢。我很抱歉有一段时间没有更新这个问题。

使用 DynaTrace,我们能够确定这是 Spring Integration 的问题。具体来说,SimpleMessageStore 似乎持有对象并填满!

dynaTrace 快照

阅读文档似乎我应该使用MessageReaper,但即使在配置中包含它之后,我也看到了同样的问题。我应该查看 SimpleMessageStore 的容量设置吗?

4

2 回答 2

0

在 ehcache 缓存配置中使用“maxBytesLocalHeap”来限制堆使用,而不是“maxElementsInMemory”。

于 2013-12-14T13:53:02.980 回答
0

在您的 ehcache 配置中,如果您想指定内存限制,我看不到任何内存限制,您必须在 ehcache 标记上设置“maxBytesLocalHeap”属性。

Ehcache 文档了解更多信息: http ://ehcache.org/documentation/configuration/cache-size#mixed-sizing-configurations 。

于 2013-09-20T15:04:04.527 回答