Closed Aloren closed 5 years ago
The current solution is to reduce maxSocketIdle. We will investigate using a LIFO stack instead of the current FIFO queue for the connection pools. The LIFO stack implementation will trim unused connections more aggressively because older connections are used much less than active connections.
Java client 4.3.1 has been released which use a LIFO stack for all connection pools. Expired connections are closed/removed once every 30 tend iterations (~30 seconds). Your test code now results in only 2 sync connections left in the pool when case 2 completes.
We are using blocking Aerospike Client Api ver. 4.3.2. In case we have requests spike on service -- client creates a lot more connections than service would need during normal load. As soon spike is gone we expect connection pool to decrease in size, but this is not happening.
According to
com.aerospike.client.cluster.Node
connections are taken from the head of the queue, after used put back in the tail. After each connection usage, it'slastUsed
time is updated. Whether connection is valid is determined by this code:If that returns false -- connection is closed and removed from the pool. By default
maxSocketIdle
is 55 seconds, it means that for at least one connection to become invalid -- application needs to traverse the whole queue in 55 seconds. That is quite a long period of time and as a result we see a big number of connections to Aerospike until we restart the service. What would you recommend doing in this situation? Would be decrease ofmaxSocketIdle
to ~5 seconds a good solution or not?I've created simple test case that reproduces this situation:
As you can see from the output after 7000 iterations * 10 ms = 70 sec, pool did not change: