telefonicaid / fiware-cygnus

A connector in charge of persisting context data sources into other third-party databases and storage systems, creating a historical view of the context
https://fiware-cygnus.rtfd.io/
GNU Affero General Public License v3.0
65 stars 104 forks source link

add max and min pool idle config for sql sinks #2367

Closed AlvaroVega closed 2 months ago

AlvaroVega commented 2 months ago

Related https://github.com/telefonicaid/fiware-cygnus/issues/2366

doc about GenericObjectPool https://commons.apache.org/proper/commons-pool/apidocs/org/apache/commons/pool2/impl/GenericObjectPool.html

$ psql -h localhost -U postgres 
SELECT datname, count(*) FROM pg_stat_activity
  WHERE state = 'idle' GROUP BY datname;

This PR allows change:

And fixes default initial values for:

With the following meanings: // Sets the cap on the number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time. gPool.setMaxActive(this.maxPoolSize);

// Sets the cap on the number of "idle" instances in the pool. gPool.setMaxIdle(this.maxPoolIdle);

// Sets the minimum number of objects allowed in the pool before the evictor thread (if active) spawns new objects. gPool.setMinIdle(this.minPoolIdle);

// Sets the minimum amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object evictor (if any) gPool.setMinEvictableIdleTimeMillis(this.minPoolIdleTimeMillis);

// Sets the number of milliseconds to sleep between runs of the idle object evictor thread gPool.setTimeBetweenEvictionRunsMillis(this.minPoolIdleTimeMillis*3)

how to see number of idle connections:

AlvaroVega commented 2 months ago

This is a example about how now cygnus uses a connection, then changes to idle and finally is released

Screenshot from 2024-04-16 11-32-57