简体   繁体   English

ehcache中的动态缓存大小

[英]Dynamic cache sizes in ehcache

I'm using ehcache 2.8.2 (migrated from 1.6.2) on a large reporting application. 我在大型报表应用程序上使用ehcache 2.8.2(从1.6.2迁移)。 Due to out of memory errors, I'm changing the configuration from being bounded by the number of elements (maxElementsInMemory) to being bounded to heap memory (maxBytesLocalHeap/maxBytesLocalDisk) on the cacheManager level . 由于内存不足错误,我正在将配置从受元素数(maxElementsInMemory)限制更改为与cacheManager级别上的堆内存(maxBytesLocalHeap / maxBytesLocalDisk)绑定。 Unfortunately, this is not working very well. 不幸的是,这不是很好。

The application has around 100 caches (one for each report). 该应用程序大约有100个缓存(每个报告一个)。 This makes it convenient to manage the caches separately. 这样可以方便地分别管理缓存。 However, when using a maxBytes configuration to pool the heap space between the caches, each cache only takes 1/100 of the pool. 但是,当使用maxBytes配置在缓存之间缓存堆空间时,每个缓存仅占用该池的1/100。 The application would have around 5 or 6 caches in use at a given moment, so this constraint is massively inefficient in our case. 在给定时刻,该应用程序将使用约5或6个缓存,因此在我们的情况下,此约束的效率非常低。

What we would like to do is to have maxBytesLocalHeap as the limit size of all caches, but each cache could take the amount of memory it needs, without being bounded to 1/100 of the size of the pool (Perhaps using LRU across caches). 我们想做的是将maxBytesLocalHeap作为所有缓存的限制大小,但是每个缓存可以占用所需的内存量,而不会限制为池大小的1/100(也许跨缓存使用LRU) 。 Of course, the sum of the size of all caches should be smaller than the pool. 当然,所有高速缓存的大小之和应小于池。

Is this possible to do with ehcache? 这可能与ehcache有关吗? What alternatives would you suggest in this case? 在这种情况下,您会建议什么替代方案?

You could try monitoring free memory in your vm and adapting EhCache CacheInstance CacheConfigurations respectively. 您可以尝试监视虚拟机中的可用内存并分别调整EhCache CacheInstance CacheConfigurations。 Reduce them when less memory and increase when more memory. 减少内存时减少它们,而增加内存时增加它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM