Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
704 views
in Technique[技术] by (71.8m points)

amazon web services - Node.js maxing out at 1000 concurrent connections

We're benchmarking node performance using a simple Hello World node server on AWS (EC2).

No matter what size instance we use Node always appears to max out at 1000 concurrent connections (this is NOT 1000 per second, but 1000 it can handle at 1 time). Shortly after that the CPU spikes and node basically freezes.

Node v0.10.5

var http = require('http');
var server = http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('loaderio-dec86f35bc8ba1b9b604db6c328864c1');
});
server.maxHeadersCount = 0;
server.listen(4000);

Node should be able to handle more than this correct? Any thoughts would be greatly appreciated.

Also the file descriptors (soft, hard, system) are set to 65096)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the posix module to raise the limit on the number of file descriptors your process can use.

Install posix

npm install posix

Then in your code that runs when you launch your app...

var posix = require('posix');

// raise maximum number of open file descriptors to 10k,
// hard limit is left unchanged
posix.setrlimit('nofile', { soft: 10000 });

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...