Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-9023

Eviction profile for “memory” type is different from “count” type

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Minor
    • None
    • 9.1.1.Final
    • Eviction
    • None

    Description

      I would like to use Infinispan as cache for image binary data (Java type byte[]). I assume that Infinispan default strategy is LIFO or similar strategy that prefers to keep most recently used/added cache entity.

      In my loadtest scenario I make four calls in the round to retrieve the same entity. It is assumed that first call never hits the cache (because each round a unique entity is requested), but following three always hit the cache. So the expected profile should look like this:

      #1: MISS-HIT-HIT-HIT
      #2: MISS-HIT-HIT-HIT
      ...
      

      It works perfectly (exactly as expected above) when I configure Infinispan with COUNT eviction type with some number of entities:

      <local-cache name="imagesCache" statistics="true">
          <!-- lifespan="30 min" max-idle="30 min" interval="1 min" -->
          <expiration lifespan="1800000" max-idle="1800000" interval="60000" />
          <memory>
              <binary eviction="COUNT" size="500" />
          </memory>
      </local-cache>
      

      Cache hit ratio based on numbers I capture in loadtest: (2952-738)/2952 = 0.75 and that matches the stats I observe via JMX.

      When I change the number of entities to keep in the memory (<binary eviction="COUNT" size="100" />), hit ratio does not change (as expected).

      After that I have restarted the application with only this small change in cache configuration:

      <memory>
          <binary eviction="MEMORY" size="1000000" />
      </memory>
      

      I would expect that Infinispan performance has the same profile, however it turns out that once the given amount of memory is fully allocated, newly added entities don't evict old entities but get immediately evicted. It means that roughly after 100 entities are added, all four requests to cache result cache miss (the ratio is now 0.58 instead of 0.75):

      #1: MISS-HIT-HIT-HIT
      #2: MISS-HIT-HIT-HIT
      ...
      #101: MISS-MISS-MISS-MISS
      ...
      

      If I increase the memory, indeed hit ratio comes closer to 0.75 however I would like hit ratio to be the same irrespective the memory size (provided that memory can fit at least few entities).

      Once I configure the passivation to file, memory-based eviction policy starts to work as expected:

      <local-cache name="imagesCache" statistics="true">
          <expiration lifespan="1800000" max-idle="1800000" interval="60000" />
          <persistence passivation="true">
              <file-store path="/var/cache/infinispan" purge="true">
                  <write-behind thread-pool-size="5" />
              </file-store>
          </persistence>
          <memory>
              <binary eviction="MEMORY" size="1000000" />
          </memory>
      </local-cache>
      

      but I would like to force the profile I need without passivation enabled.

      Additional information is provided on the forum.

      Bottomline: If underlying component supports different eviction "modes", please expose this setting via XML so that the user of the library can control the mode.

      Attachments

        Issue Links

          Activity

            People

              wburns@redhat.com Will Burns
              dma_k Dmitry Katsubo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: