coopernurse / node-pool

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

Cpu/memory usage goes up when version is higher than 2.4.3 #177

Open George0406 opened 7 years ago

George0406 commented 7 years ago

When I using generic-pool which version is 2.5.4 and run in the docker container, its cpu/memory usage will rise continuously, but it doesn't happen when I use version 2.4.3 . So are there any difference between these two version and does anyone has same problem as me?

sandfox commented 7 years ago

Hi @George0406

What version of nodejs are you running and do you have any script or example to be able to reproduce this with?

What sort of numbers are you seeing in terms of cpu/memory consumption and over what sort of time frame?

The actual changes between the two versions are below. https://github.com/coopernurse/node-pool/compare/v2.4.3...v2.5.4

George0406 commented 7 years ago

Hi @sandfox, Thanks for your reply. My current node version is 6.9.1 and docker version is 1.12.1, after I start my program and the initial cpu usage is 3% and it will increase slowly until 70% or more, and I had try another version 3.X and it didn't happen this problem. I just use generic-pool with ioredis simply.

sandfox commented 7 years ago

Without having the code to reproduce or idea of the configuration this I'm limited to some guesswork.

Something it might be worth doing is putting some logging in the application that outputs the current pool stats every few seconds/minutes

var pool; // some previously created generic-pool instance

var poolLogger  = function(){
  var poolStats = {
    max: pool.getMaxPoolSize(),
    min: pool.getMinPoolSize(),
    size: pool.getPoolSize(),
    available: pool.availableObjectsCount(),
    waiting: pool. waitingClientsCount(),
  }
   console.log('pool stats: ',  poolStats)
}
setTimeout(poolLogger, 1000)

it could also be worth tracking how many acquire/release calls you are making per second/minute. generic pool by itself shouldn't be that CPU intensive, unless you are destroying and recreating resources

version 3 is a near complete rewrite and the internals are completely different.

George0406 commented 7 years ago

Thank you @sandfox, I will record log what you mentioned, and observe what is the difference between 2.4.3 and 2.5.4