FAILING WITH
NOT
The PROJECT
The PROMISE
1,250
Concurrent
USERS
The REALITY
1000?
750?
500?
300?
The REALITY
1
5
0
USERS per CORE
1250/150 = 8+ cores
The SYMPTOMS
web server = high
CPU USAGE
DATABASE = LOW
The DIAGNOSTIC
PROFILING (Round 1)
$ node --prof # generates a v8.log file
$ npm install -g profiler
$ nprof # generates nice output from the log file
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 2.0% are not shown.
ticks parent name
87455 43.9% /usr/local/bin/node
3188 3.6% LazyCompile: *DefineObjectProperty native v8natives.js:695
3186 99.9% LazyCompile: *DefineOwnProperty native v8natives.js:924
3184 99.9% LazyCompile: defineProperty native v8natives.js:1050
1538 48.3% LazyCompile: Instance.addInstanceProperty /Users/jfacorro/work/battles/node_modules/orm/lib/Instance.js:475
1538 100.0% LazyCompile: Instance /Users/jfacorro/work/battles/node_modules/orm/lib/Instance.js:8
1047 32.9% LazyCompile: Instance /Users/jfacorro/work/battles/node_modules/orm/lib/Instance.js:8
1043 99.6% LazyCompile: Model.createInstance /Users/jfacorro/work/battles/node_modules/orm/lib/Model.js:50
547 17.2% LazyCompile: *extendInstance /Users/jfacorro/work/battles/node_modules/orm/lib/Associations/One.js:144
510 93.2% LazyCompile: *exports.extend /Users/jfacorro/work/battles/node_modules/orm/lib/Associations/One.js:119
37 6.8% LazyCompile: ~exports.extend /Users/jfacorro/work/battles/node_modules/orm/lib/Associations/One.js:119
2564 2.9% LazyCompile: *createWriteReq net.js:658
...
The CURE
DB ACCESS (Round 1)
Sequelize
NODE-ORM
The DIAGNOSTIC
PROFILING (Round 2)
$ node --prof # generates a v8.log file
$ npm install -g profiler
$ nprof # generates nice output from the log file
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 2.0% are not shown.
ticks parent name
87455 43.9% /usr/local/bin/node
3188 3.6% LazyCompile: *DefineObjectProperty native v8natives.js:695
3186 99.9% LazyCompile: *DefineOwnProperty native v8natives.js:924
3184 99.9% LazyCompile: defineProperty native v8natives.js:1050
1538 48.3% LazyCompile: Instance.addInstanceProperty /Users/jfacorro/work/battles/node_modules/orm/lib/Instance.js:475
1538 100.0% LazyCompile: Instance /Users/jfacorro/work/battles/node_modules/orm/lib/Instance.js:8
1047 32.9% LazyCompile: Instance /Users/jfacorro/work/battles/node_modules/orm/lib/Instance.js:8
1043 99.6% LazyCompile: Model.createInstance /Users/jfacorro/work/battles/node_modules/orm/lib/Model.js:50
547 17.2% LazyCompile: *extendInstance /Users/jfacorro/work/battles/node_modules/orm/lib/Associations/One.js:144
510 93.2% LazyCompile: *exports.extend /Users/jfacorro/work/battles/node_modules/orm/lib/Associations/One.js:119
37 6.8% LazyCompile: ~exports.extend /Users/jfacorro/work/battles/node_modules/orm/lib/Associations/One.js:119
2564 2.9% LazyCompile: *createWriteReq net.js:658
...
The CURE
DB ACCESS (Round 2)
Node-ORM
node-pg + REPOS
The NEW REALITY
3
5
0
USERS PER CORE
The NEW REALITY
350 vs 150
233% Improvement
1250/150 = 8+ cores
1250/350 = 3.5 cores
The NEW REALITY
PWN3D
THE END
node.js - Battles
By Juan Facorro
node.js - Battles
How to deal with a node.js project not reaching the desired number of requests per second. (ORM, node.js, profiling)
- 544