You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having trouble getting my pool keep a minimum number of resources alive. Essentially, I want to have at least 4 available at all times and spawn up to 4 more when load becomes heavier.
This is my code:
this.generatorPool = poolModule.Pool({
name: 'generator-pool',
create: function (resolveResource) {
var generator = new Generator();
generator.start().then(
// Generator load successful
function() {
resolveResource(null, generator);
},
// Generator failed to load
function () {
resolveResource(new Error('Failed to load generator'));
}
);
},
destroy: function (generator) {
console.log('DESTROYING THE GENERATOR)
generator.stop();
},
max: 8,
min: 4,
refreshIdle: false,
idleTimeoutMillis: 30000
});
For some reason the first 4 resources are still being destroyed after 30 seconds. What could be up?
The text was updated successfully, but these errors were encountered:
Once each of the first 4 resources are destroyed are they being replaced by another set of resources? (i.e does the pool always have 4 resources in it, because that should be what is happening)
The resources are getting destroyed after 30 seconds because of the idleTimeoutMillis: 30000.
Looking at it closer I see the problem is different than I originally thought. When I have the minimum set to 4 the pool does start to spawn 4 resources when its created. However, immediately after the pool creation I call acquire 4 times. This starts up an ADDITIONAL 4 resources instead of waiting for the first 4 to finish initializing and using them. Those 4 additional resources were what I was seeing get destroyed. Its not a huge deal for me since this can only happen at startup.
I can understand fixing that issue might not be worth the complexity.
I'm having trouble getting my pool keep a minimum number of resources alive. Essentially, I want to have at least 4 available at all times and spawn up to 4 more when load becomes heavier.
This is my code:
For some reason the first 4 resources are still being destroyed after 30 seconds. What could be up?
The text was updated successfully, but these errors were encountered: