This discussion is archived
11 Replies Latest reply: May 15, 2012 8:52 AM by robvarga RSS

Coherence Object Expiry Process

694568 Newbie
Currently Being Moderated
how does coherence expire objects after the objects honor their TTL? For instance, "A" object is put into the cache with ttl 2 hours. After 2 hours, how does coherence get rid of this object from the cache thereby freeing up the memory? What is the process that kicks off expiry?
  • 1. Re: Coherence Object Expiry Process
    user738616 Pro
    Currently Being Moderated
    Hi,
    how does coherence expire objects after the objects honor their TTL? For instance, "A" object is put into the cache with ttl 2 hours. After 2 hours, how does coherence get rid of this object from the cache thereby freeing up the memory? What is the process that kicks off expiry?
    The expiry is kicked off when an operation (get,put) is invoked against the cache. So, if there is no activity at the time of expiry the object will continue to stay in the heap and will be removed only when a request (req) is made to the cache. This removal will be done by the same thread that made this request (req)

    Hope this helps!

    Cheers,
    NJ
  • 2. Re: Coherence Object Expiry Process
    694568 Newbie
    Currently Being Moderated
    thanks for clarifying that. Now, you said that the same request (put/get) thread does expiry. what-if there are quite a few objects to be expired when a request is made, this would affect performance of my put/get request right?
  • 3. Re: Coherence Object Expiry Process
    user738616 Pro
    Currently Being Moderated
    Hi,

    Yes, it will affect the performance of that unfortunate request. But, AFAIK if there are too many entries to be expired at the same time then these expiries are distributed across multiple requests/scans.

    Hope this helps!

    Cheers,
    NJ
  • 4. Re: Coherence Object Expiry Process
    robvarga Oracle ACE
    Currently Being Moderated
    user738616 wrote:
    Hi,
    how does coherence expire objects after the objects honor their TTL? For instance, "A" object is put into the cache with ttl 2 hours. After 2 hours, how does coherence get rid of this object from the cache thereby freeing up the memory? What is the process that kicks off expiry?
    The expiry is kicked off when an operation (get,put) is invoked against the cache. So, if there is no activity at the time of expiry the object will continue to stay in the heap and will be removed only when a request (req) is made to the cache. This removal will be done by the same thread that made this request (req)

    Hope this helps!

    Cheers,
    NJ
    Hi NJ,

    I think this requires a bit clarification, I believe it is not the requesting thread but the worker thread carrying out the request on that backing map is which does eviction handling.

    Best regards,

    Robert
  • 5. Re: Coherence Object Expiry Process
    robvarga Oracle ACE
    Currently Being Moderated
    user738616 wrote:
    Hi,

    Yes, it will affect the performance of that unfortunate request. But, AFAIK if there are too many entries to be expired at the same time then these expiries are distributed across multiple requests/scans.

    Hope this helps!

    Cheers,
    NJ
    Hi NJ,

    that can partly be true. If there are multiple backing maps which each get to the limit, then they each are going to be pruned in parallel.

    But on a single backing map, as I understand, only a single thread is going to do eviction. The reason is that eviction policies are not required to be thread-safe, so I expect Coherence invokes the eviction policy on a single thread at a time within a synchronized block. It is very easy to verify it, and it looks to be that way.

    On the other hand, nothing prevents your EvictionPolicy code from making evictions from other thread(s) it spawned, thus you can make it multi-threaded, but that would also mean that the high-limit can not be a hard limit anymore as eviction would be asynchronous in that case (and would have to go through the front door (NamedCache.remove or NamedCache.invoke/invokeAll), so it would not necessarily spawn synthetic events).

    Best regards,

    Robert

    Edited by: robvarga on May 15, 2012 11:13 AM
  • 6. Re: Coherence Object Expiry Process
    alexey.ragozin Explorer
    Currently Being Moderated
    Hi,

    Size() method is also triggering expiration to kick off. Sometimes I use it to make sure that cache is not full of dead entries (e.g. You have no activity during night hours so first request in the morning may trigger a lot of expiration events).

    Funny things may happen if expiration is kicking of in the middle of request. E.g entry set provided for aggregator to process may be partially expired.

    --
    Alexey
  • 7. Re: Coherence Object Expiry Process
    694568 Newbie
    Currently Being Moderated
    I don't want us to mix eviction with expiry. If we can just stick to expiry here, unless one influences the other.
  • 8. Re: Coherence Object Expiry Process
    user738616 Pro
    Currently Being Moderated
    Hi Robert,
    robvarga wrote:
    user738616 wrote:
    Hi,
    how does coherence expire objects after the objects honor their TTL? For instance, "A" object is put into the cache with ttl 2 hours. After 2 hours, how does coherence get rid of this object from the cache thereby freeing up the memory? What is the process that kicks off expiry?
    The expiry is kicked off when an operation (get,put) is invoked against the cache. So, if there is no activity at the time of expiry the object will continue to stay in the heap and will be removed only when a request (req) is made to the cache. This removal will be done by the same thread that made this request (req)

    Hope this helps!

    Cheers,
    NJ
    Hi NJ,

    I think this requires a bit clarification, I believe it is not the requesting thread but the worker thread carrying out the request on that backing map is which does eviction handling.

    Best regards,

    Robert
    Yes, I agree it will be done by the worker thread(s) but, if the thread pool is configured for the service else will be carried on the service thread.

    Cheers,
    NJ
  • 9. Re: Coherence Object Expiry Process
    user738616 Pro
    Currently Being Moderated
    Hi Robert,
    robvarga wrote:
    user738616 wrote:
    Hi,

    Yes, it will affect the performance of that unfortunate request. But, AFAIK if there are too many entries to be expired at the same time then these expiries are distributed across multiple requests/scans.

    Hope this helps!

    Cheers,
    NJ
    Hi NJ,

    that can partly be true. If there are multiple backing maps which each get to the limit, then they each are going to be pruned in parallel.

    But on a single backing map, as I understand, only a single thread is going to do eviction. The reason is that eviction policies are not required to be thread-safe, so I expect Coherence invokes the eviction policy on a single thread at a time within a synchronized block. It is very easy to verify it, and it looks to be that way.
    I meant if the number of entries to be expired for the backingMap(s) are too many then as I understand the expiry process will be spread across multiple request(s) by the Coherence internally.
    On the other hand, nothing prevents your EvictionPolicy code from making evictions from other thread(s) it spawned, thus you can make it multi-threaded, but that would also mean that the high-limit can not be a hard limit anymore as eviction would be asynchronous in that case (and would have to go through the front door (NamedCache.remove or NamedCache.invoke/invokeAll), so it would not necessarily spawn synthetic events).
    I am not sure if a CustomPolicy can be configured for the expiry of the objects.

    Cheers,
    NJ

    Edited by: user738616 on May 15, 2012 8:48 AM
  • 10. Re: Coherence Object Expiry Process
    robvarga Oracle ACE
    Currently Being Moderated
    walk_the_talk wrote:
    I don't want us to mix eviction with expiry. If we can just stick to expiry here, unless one influences the other.
    Sorry, I overlooked that part, although it does not really matter.

    According to my tests, expiry also seems to be occuring on a single thread, all concurrent worker threads (at least those mutating) seem to be blocked while flushing expired data.

    Best regards,

    Robert
  • 11. Re: Coherence Object Expiry Process
    robvarga Oracle ACE
    Currently Being Moderated
    user738616 wrote:
    Hi Robert,
    robvarga wrote:
    user738616 wrote:
    Hi,
    how does coherence expire objects after the objects honor their TTL? For instance, "A" object is put into the cache with ttl 2 hours. After 2 hours, how does coherence get rid of this object from the cache thereby freeing up the memory? What is the process that kicks off expiry?
    The expiry is kicked off when an operation (get,put) is invoked against the cache. So, if there is no activity at the time of expiry the object will continue to stay in the heap and will be removed only when a request (req) is made to the cache. This removal will be done by the same thread that made this request (req)

    Hope this helps!

    Cheers,
    NJ
    Hi NJ,

    I think this requires a bit clarification, I believe it is not the requesting thread but the worker thread carrying out the request on that backing map is which does eviction handling.

    Best regards,

    Robert
    Yes, I agree it will be done by the worker thread(s) but, if the thread pool is configured for the service else will be carried on the service thread.

    Cheers,
    NJ
    Hi NJ,

    that is true in general, that if you did not configure a thread-pool (thread-count == 0) then the service thread takes the responsibility of the worker thread, but I don't mention this every time I speak about worker threads.

    My point was that it is not carried out on the requesting thread (caller of the NamedCache method), but on the worker/service thread (Coherence thread within the storage node).

    Best regards,

    Robert

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points