推荐的 Node.js Linux 内核设置



我们的节点.js应用程序将大量加载,所以我想知道是否有我应该适当配置的Linux(Ubuntu服务器)内核设置?

现在我正在考虑打开文件描述符的限制:

cat /etc/security/limits.d/nodeuser.conf
nodeuser     soft    nofile  65535
nodeuser     hard    nofile  65535

是否有任何其他内核/用户进程可调参数应该为 Node.js 提供一些推荐值?

我过去用过这个很棒的帖子:

https://engineering.gosquared.com/optimising-nginx-node-js-and-networking-for-heavy-workloads

根据我的经验,最重要的是减少连接在关闭后花费在TIME_WAIT上的时间(net.ipv4.tcp_tw_reusenet.ipv4.tcp_fin_timeout)。否则,您可能会很快用完开放端口。

如您所建议的,您还需要增加文件描述符的数量。