几个小时后节点服务器崩溃 [英] Node Server crashes after few hours

查看:182
本文介绍了几个小时后节点服务器崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Ubuntu Server上将Nodemon与Forever Module一起使用.

I am using Nodemon with Forever Module on Ubuntu Server.

我使用此命令来启动我的节点服务器:

I use this command to start my Node Server:

forever start -c nodemon app.js  --exitcrash

它可以正常工作几个小时(大约48小时),但是之后我的服务器停止工作并出现以下错误:

It works fine for few hours (approx 48 Hours), but after that my Server stops working with these errors:

Error: getaddrinfo EMFILE   
TypeError: Cannot call method 'indexOf' of undefined
Error: Handshake inactivity timeout

这些错误是由于超出打开文件/套接字的限制引起的.

These errors are caused due to Exceeding Limit of Open Files/Sockets.

现在我的问题是:

我可以使用-m(在我的操作系统中将其设置为无限制)吗?

Can I use -m (Which sets to unlimited in my Operating System):

max memnory size   (kbytes, -m) unlimited

我应该将上述命令与-m一起使用吗?有什么缺点吗?

Should I use the above command with -m? Are there any drawbacks?

还是有其他有效的解决方案来修复服务器崩溃?

Or is there any other efficient solution to fix Server crashing?

推荐答案

如果您有大量用户,则很可能是达到系统排队侦听套接字的最大请求数.如果您确定服务器可以处理负载,则可以将默认值从128增加到1024.

If you have large number of users most probably you are hitting systems maximum number of requests queued to listen socket. If you are sure your server can handle the load you can increase from default 128 to something 1024.

是的,增加ulimit,以便系统可以处理更多的负载,但不要设置为无限制,只需检查足以处理当前负载的值即可.

And yes, increase the ulimit, so system can handle more load, but don't set to unlimited, just check what is enough to handle current load.

也请通过以下增加最大数量的Linux中的TCP/IP连接 也会获得一些有用的信息

Also go through this Increasing the maximum number of tcp/ip connections in linux will get some helpful info too

这篇关于几个小时后节点服务器崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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