I'm wondering which are the advantages of a LIFO stack vs a FIFO queue in the implementation of a pool with Apache Commons Pool. Wouldn't be more "secure" to default as FIFO to avoid getting timeout connections (opened at start but not used until peak hours) and probably avoid having to test on idle?
I'd appreciate any opinions. Thank you very much.
Some advantages to LIFO (the default) can be
Whether or not these are benefits depends on what the pooled objects are, what the load distribution is, how important it is to keep workload concentrated on a small number of instances and how beneficial it is to reuse more recently used resources.
You are correct that using LIFO can cause some instances to sit idle in the pool for longer periods. If keeping the pool trimmed down and concentrating load are not advantages, timeouts are a problem and load distribution is such that FIFO access works to keep instances fresh, that configuration can make sense. This is why the configuration option is there.