简体   繁体   中英

Imitate high CPU and memory usage in NodeJS

I want to check the autoscaling behavior of our NestJS/NodeJS application inside a cluster. I want to generate CPU and/or memory usage >70% based on requests count per second. I have tried to accumulate multiplications of random numbers on every request for 1 second but seems like requests are processed one by one and never generate too much load. What would be your suggestion?

If you are trying to basically drain the computer using nodejs, the following works for me:

  1. Generate way too many random numbers and multiply them with a VERY LARGE random number
  2. Put all of the numbers above in an array and sort it
  3. Parse the list into integers
  4. Filter the list to have only primes remaining That should be enough to take up memory (as the lists aren't recycled by the GC so quickly) and the sorting and prime bits should lag out the proccess. If its too much just scale down the array size. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM