2

I am trying to consume Apache common pool library to implement an object pooling for the objects that are expensive to create in my application. For respource pooling I have used the GenericObjectPool class of the library to use the default implementation provided by API for the object pooling. In order to ensure that we do not end up having several idle objects in memory, I set up the minEvictableIdleTimeMillis and timeBetweenEvictionRunsMillis properties to 30 minutes.

As I understood from other questions, blogs and API documentation, these properties trigger a separate thread in order to evict the idle objects from pool.

Could someone help me if that has any adverse impact on application performance and if there is any way to test if that thread is actually executed or not?

1 Answers1

1
  1. Library comes with the performance disclaimer when evictor is enabled

Eviction runs contend with client threads for access to objects in the pool, so if they run too frequently performance issues may result.

reference : https://commons.apache.org/proper/commons-pool/api-1.6/org/apache/commons/pool/impl/GenericObjectPool.html

However, we have a high TPS system running eviction every 1 sec and we don't see much of a performance bottle necks.

  1. As for the eviction thread runs are concerned, you can override the evict() method in your implementation of GenericObjectPool and add a log line.

    @Override
    public void evict() throws Exception {
       //log
       super.evict();
    }
    
linkcrux
  • 328
  • 4
  • 13