node.js - Big performance loss with NodeJS loops on Amazon EC2 server -
i running amazon ec2 m1 general purpose small (1 core x 1 unit) 64 bit instance.
i've established amazon instance on average half fast computer i'm working on when using single-threaded nodejs
app:
var time = date.now(); var fibo = function(n) { return n == 0 ? 0 : n == 1 ? 1 : fibo(n-1) + fibo(n-2); }; console.log("fibo(40) = " + fibo(40)); time = date.now() - time; console.log("took: " + time + " ms");
localhost:
fibo(40) = 102334155
took:
1447 ms
amazon ec2:
fibo(40) = 102334155
took:
3148 ms
now when in bigger app iterate on big 5mb json object (5mb being formatted , indented filesize, assume smaller internally) using 6 nested for
loops (and sake of argument please assume me necessary) end 9.000.000 iterations.
on localhost, takes 8 seconds. on amazon ec2, takes 46 seconds.
i expected 20 seconds @ most.
what causes amazon lag more?
i know v8 highly optimized.
is javascript
/v8
/node.js
perhaps using optimizations aren't compatible virtual machines (like ec2 instance)?
and similarly
any special kind of code optimizations recommended crazy stuff this?
Comments
Post a Comment