EHCache heap and off-heap evaluate resources enough to use?

1.9k Views Asked by At

EHCache version 3.2

How do I evaluate "ehcache:resources" ?

File: ehcache.xml

<ehcache:cache alias="messageCache">
    <ehcache:key-type>java.lang.String</ehcache:key-type>
    <ehcache:value-type>org.cache.messageCacheBean</ehcache:value-type>
    <ehcache:resources>
        <ehcache:heap unit="entries">10</ehcache:heap>
        <ehcache:offheap unit="MB">1</ehcache:offheap>
    </ehcache:resources>
</ehcache:cache>

Assume.

Table Name: Message have 4 columns type varchar2(100 Byte) and have data 1000 rows or more than in the database.

How much provide enough define heap/offheap value ?

Thank you.

1

There are 1 best solutions below

0
On

Sizing caches is part of the exercise and does not really have a general answer.

However, understanding a bit how Ehcache works is needed. In the context of your configuration:

  • All mappings will always be present in offheap. So this tier should be sized large enough to balance the memory usage / latency benefits that match your application needs.
  • The onheap tier will be used for the hot set, giving even better latency reduction. However if too small, it will be evicting all the timing, making its benefit less intersting but if too large it impacts Java garbage collection too much as well.

One thing you can do to help onheap tier sizing is to move to byte size in one test. While it will have a performance impact, it will enable you to evaluate how much memory a mapping takes. And thus derived how much mapping fit in the memory you are ready to spare.