我使用node
在localhost
的{{1}}应用中测试流量。我每5秒生成10000个请求。
问题是当我运行命令http.get()
并且在20到30秒之后服务器崩溃并出现以下错误
npm start
我使用events.js:136
throw er; // Unhandled 'error' event
^
Error: connect EADDRNOTAVAIL localhost:8000 - Local (localhost:0)
at Object._errnoException (util.js:999:13)
at _exceptionWithHostPort (util.js:1020:20)
at internalConnect (net.js:987:16)
at net.js:1087:9
at process._tickCallback (internal/process/next_tick.js:150:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@1.0.0 start: `node ./bin/run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kd/.npm/_logs/2018-03-28T08_32_26_105Z-debug.log
这是我的app.js
16.04.1-Ubuntu
这里是rob.js
var rob = require('./test/rob.js');
for (var i = 0; i < 10000; i++) {
rob.init();
}
这里是run.js
var http = require('http');
module.exports = {
init : function(){
var pages = [
'dashboard',
'home',
'login',
'contact',
'support',
'about'
];
setInterval(function(){
try{
var pg = pages[Math.round(Math.random() * 5)];
http.get('http://localhost:8000/' + pg,
res => {
console.log('RES =>','SUCCSESS');
},
err => {
console.log('ERROR','ERROR');
});
}catch(err){
console.log('ER','ERR');
}
},5000);
}
}
如何解决此问题?
还有其他方法可以检查流量吗?