2016-11-24 95 views
0

我用快遞靜態插件,Windows 2008的64位,8G內存,萬兆網,節點-6.9.x 64位集羣的NodeJS高內存使用率

var cluster = require("cluster"); 
var http = require("http"); 
var express = require("express"); 
if(cluster.isMaster()){ 
    for (var i = 0; i < 4; i++) 
    cluster.fork(); 
}else{ 
    var express = require("express"); 
    var app = express(); 
    var http = require("http"); 
    app.use(express.static("")); 
    http.createServer(app).listen(8080); 
} 

記憶增長速度非常快,從1GB到8G的約五minutes.at這次約1500 connections.outgoing帶寬300MB /萬兆,約150MB,主進程30MB每一個工作進程。

System performance monitor show 
----------------------------------------------------------------- 
receive|   using 7.8G      | free 100Mb 
--------------------------------------------------------------- 

內存所使用的是誰?大約15分鐘,工作人員進程崩潰。

我嘗試HTTP服務器模塊(NPM安裝HTTP服務器),相同的結果。

+0

你怎麼做1500間的連接測試? – iKoala

+0

系統性能監視器 - > TCPv4 - >連接活動 – Luodong

+0

我不明白爲什麼這個示例代碼默認會創建1500個連接。 – iKoala

回答

0

我使用AB測試我的筆記本電腦10秒測試代碼(帶有一點點的變化),效果很好。 變化是cluster.isMasterapp.use(express.static("/"));

var cluster = require("cluster"); 
var http = require("http"); 
var express = require("express"); 
if(cluster.isMaster){ 
    for (var i = 0; i < 4; i++) 
    cluster.fork(); 
}else{ 
    var express = require("express"); 
    var app = express(); 
    var http = require("http"); 
    app.use(express.static("/")); 
    http.createServer(app).listen(8080); 
} 

結果是:

Benchmarking 127.0.0.1 (be patient) 
Completed 5000 requests 
Completed 10000 requests 
Completed 15000 requests 
Completed 20000 requests 
Completed 25000 requests 
Finished 26960 requests 


Server Software: 
Server Hostname:  127.0.0.1 
Server Port:   8080 

Document Path:  /
Document Length:  13 bytes 

Concurrency Level:  300 
Time taken for tests: 10.023 seconds 
Complete requests:  26960 
Failed requests:  0 
Write errors:   0 
Non-2xx responses:  27097 
Total transferred:  5717467 bytes 
HTML transferred:  352261 bytes 
Requests per second: 2689.93 [#/sec] (mean) 
Time per request:  111.527 [ms] (mean) 
Time per request:  0.372 [ms] (mean, across all concurrent requests) 
Transfer rate:   557.09 [Kbytes/sec] received 

Connection Times (ms) 
       min mean[+/-sd] median max 
Connect:  0 0 3.1  0  498 
Processing: 94 109 46.2 104  609 
Waiting:  12 79 48.5  77  567 
Total:   94 109 46.3 104  609 
+0

是的,我也測試局域網。沒問題,我的服務器運行在互聯網上,我覺得慢連接影響。靜態文件約1MB〜。 – Luodong

+0

靜態插件使用發送模塊,發送模塊最終使用pipe,由於連接速度慢,系統Cache? – Luodong

+0

以上代碼來自哪裏?你能否顯示所有的代碼? – jiajianrong