ehcache / ehcache3

Ehcache 3.x line

Home Page:http://www.ehcache.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

High latency for the first cache hit when using persistent disk tier option

sgup432 opened this issue · comments

commented

I was trying ehcache as a disk tier cache only option and running some benchmarks. I ran multiple iterations to fetch a specific key from ehcache and observed high latency from first cache hits when compared to the rest of the iterations.
Something like(doing multiple cache gets with same key):
2sec(cache_miss_latency), 30ms(first cache hit), 1ms, 2ms, 1ms ....... so on.

I cached bunch of data and was trying to get a specific key multiple times.

I wanted to know why this behaviour ie first cache hit is expensive, is it because it reads from disk for first time and promotes to offheap for later retrievals?

Also I deleted the folder where ehcache data is stored and it was still able to serve reads and writes(surprisingly). Need an explanation for this as well.

Ehcache uses a tiering system. Yes, an entry that was just read from the cache is likely to be promoted in to an in-memory tier (offheap and/or heap).

Additionally, your OS is likely caching your file system, so a second lookup is likely to be faster even if from disk.

Lastly, 2 seconds is an eternity. Guessing that the disk is maybe virtual/network based? Are you also measuring JVM warm-up (JIT) time?