Wednesday, April 18, 2018

node.js - NodeJS, Promises and performance

My question is about performance in my NodeJS app...



If my program run 12 iteration of 1.250.000 each = 15.000.000 iterations all together - it takes dedicated servers at Amazon the following time to process:





r3.large: 2 vCPU, 6.5 ECU, 15 GB memory --> 123 minutes



4.8xlarge: 36 vCPU, 132 ECU, 60 GB memory --> 102 minutes




I have some code similair to the code below...




start();


start(){

for(var i=0; i<12; i++){

function2(); // Iterates over a collection - which contains data split up in intervals - by date intervals. This function is actually also recursive - due to the fact - that is run through the data many time (MAX 50-100 times) - due to different intervals sizes...
}
}

function2(){


return new Promise{

for(var i=0; i<1.250.000; i++){
return new Promise{
function3(); // This function simple iterate through all possible combinations - and call function3 - with all given values/combinations
}
}
}
}



function3(){
return new Promise{ // This function simple make some calculations based on the given values/combination - and then return the result to function2 - which in the end - decides which result/combination was the best...
}}



This is equal to 0.411 millisecond / 441 microseconds pér iteration!




When i look at performance and memory usage in the taskbar... the CPU is not running at 100% - but more like 50%...the entire time?
The memory usage starts very low - but KEEPS growing in GB - every minute until the process is done - BUT the (allocated) memory is first released when i press CTRL+C in the Windows CMD... so its like the NodeJS garbage collection doesn't not work optimal - or may be its simple the design of the code again...



When i execute the app i use the memory opt like:




node --max-old-space-size="50000" server.js




PLEASE tell me every thing you thing i can do - to make my program FASTER!




Thank you all - so much!

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...