what is the difference between persistent="true" vs false while configuring disk tier in ehcache3 ?

659 views
Skip to first unread message

himansu

unread,
Aug 23, 2017, 7:01:51 AM8/23/17
to ehcache-users

Hi

 

i have configured ehcache 3.1 on jdk 8 with this config. i went through the documentation couple of time and still not clear on few things.

can you guys help me understand:


<ehcache:cache alias="cache1">
<ehcache:key-type>java.lang.String</ehcache:key-type>
<ehcache:value-type>userdefined object</ehcache:value-type>
<ehcache:resources>
<ehcache:heap unit="entries">10</ehcache:heap>
<ehcache:disk unit="MB" persistent="true">100</ehcache:disk>
</ehcache:resources>
</ehcache:cache>

1. what is the difference between persistent=false vs persistent=true  while configuring ehcache3 disk tier ?

i was thinking if i set persistent=false, ehcache will use a tmp swap space(and thereby increase the disk write performance ?) but i see files are getting created on disk regardless of the value i set.


2. is there a way to know when a entry in cache is moved to a slower tier(for e.g. from heap to disk) ?

In the above config, the max entries  on heap is 10 with a disk tier.

 i have also configured cache event listeners.

but i dont see any related events getting triggered when i start inserting 11 th entry to cache ?


3.i am not using offheap tier, but i see the disk files are getting created in a folder called  "off-heap" on the disk.does that mean ehcache3 is using offheap tier ?



Louis Jacomet

unread,
Aug 23, 2017, 7:10:04 AM8/23/17
to ehcach...@googlegroups.com
Hi,

Find answers inline.

Regards,
Louis

On Wed, Aug 23, 2017 at 1:01 PM himansu <dhima...@gmail.com> wrote:

Hi

 

i have configured ehcache 3.1 on jdk 8 with this config. i went through the documentation couple of time and still not clear on few things.

can you guys help me understand:


<ehcache:cache alias="cache1">
<ehcache:key-type>java.lang.String</ehcache:key-type>
<ehcache:value-type>userdefined object</ehcache:value-type>
<ehcache:resources>
<ehcache:heap unit="entries">10</ehcache:heap>
<ehcache:disk unit="MB" persistent="true">100</ehcache:disk>
</ehcache:resources>
</ehcache:cache>

1. what is the difference between persistent=false vs persistent=true  while configuring ehcache3 disk tier ?

i was thinking if i set persistent=false, ehcache will use a tmp swap space(and thereby increase the disk write performance ?) but i see files are getting created

on disk regardless of the value i set.

That attribute indicates whether or not Ehcache will try to preserve the disk tier data between JVM restarts.
With persistent="false" Ehcache will wipe the disk data on shutdown.
With persistent="true" Ehcache will preserve the disk data on shutdown and try to load it back on restart of the JVM.


2. is there a way to know when a entry in cache is moved to a slower tier(for e.g. from heap to disk) ?

In the above config, the max entries  on heap is 10 with a disk tier.

 i have also configured cache event listeners.

but i dont see any related events getting triggered when i start inserting 11 th entry to cache ?


Ehcache _always_ writes all entries to the lower (slower) tiers in oder to offer predictable latency. When accessed, mappings are moved to the higher tier(s) for subsequent faster access. See http://www.ehcache.org/documentation/3.3/caching-concepts.html#storage-tiers for details. 

3.i am not using offheap tier, but i see the disk files are getting created in a folder called  "off-heap" on the disk.does that mean ehcache3 is using offheap tier ?


What Ehcache uses are memory mapped files, which rely on our offheap library. But if you are using the disk tier, no you are not using RAM. 


--
You received this message because you are subscribed to the Google Groups "ehcache-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-user...@googlegroups.com.
To post to this group, send email to ehcach...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/78c58ff3-40ec-4ec5-a8e6-914043988887%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

himansu

unread,
Sep 22, 2017, 5:50:20 PM9/22/17
to ehcache-users
Thanks Louis for the reply.
I have couple of follow up questions on the same.
Is the disk writes in ehcache happen asynchronously by default  ?
If so is there a way to know when the disk write is triggered ?
i was running a test case where i was persisting avro messages to ehcache(with disk tier configured) and found that the moment i do a put , my custom serializer was getting called.
does this mean the disk write is also happening in the same thread.
I found this step of storing data to cache is impacting performance(for 20k avro messages it was taking 25 seconds.)
Is there a way to handle the object serialization in a different thread ?

Thanks
Himansu

himansu

unread,
Oct 30, 2017, 11:29:10 AM10/30/17
to ehcache-users
Hi Louis,
can you help clarify below ?
Reply all
Reply to author
Forward
0 new messages