coopernurse / node-pool

Generic resource pooling for node.js
2.38k stars 259 forks source link

Idle Object Eviction is performed one by one #200

Closed C-h-e-r-r-y closed 5 years ago

C-h-e-r-r-y commented 7 years ago

Consider the following pool configuration:

        idleTimeoutMillis: 5000,
        softIdleTimeoutMillis: 5000,
        maxUses: 0,
        evictionRunIntervalMillis: 60 * 1000,

At the begining there are 6 phantom processes. And they evidicted one by opne with evictionRunIntervalMillis. So after 1 minute there 5 processes, after 2 minutes 4 etc.

Is it correct behavior? I think with softIdleTimeoutMillis and idleTimeoutMillis every instance should be deleted after 2 minutes.

MichielDeMey commented 6 years ago

It looks like you need to set numTestsPerRun: "Number of resources to check each eviction run. Default: 3."

TsungHseinTsai commented 6 years ago

I meet the same problem. In _evict, the shouldEvict flag is set to true while the resource is defined idle, then the resource would be destroyed and removed from _evictionIterator. But the _evictionIterator.remove will make iterator to done, then break in the next loop.

sandfox commented 5 years ago

this was fixed in #243