Node.js的杏在1000个并发连接 [英] Node.js maxing out at 1000 concurrent connections

查看:132
本文介绍了Node.js的杏在1000个并发连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用的AWS(EC2)一个简单的Hello World节点服务器基准测试节点的性能。

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

无论我们使用什么尺寸实例节点似乎总是最大输出为1000个并发连接(这不是每秒1000次,但1000也可以处理1次)。不久后的CPU峰值和节点基本上冻结。

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.

节点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);

节点应该能够处理比这更正确的吗?任何想法,将大大AP preciated。

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

另外,文件描述符(软,硬,系统)设置为65096)

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

推荐答案

使用了 POSIX 模块,以提高上限的文件的数量描述你的进程可以使用。

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

安装 POSIX

npm install posix

然后在你的code运行时启动应用程序...

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 });

这篇关于Node.js的杏在1000个并发连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆