A meteor.js 0.82 app is running on an Ubuntu 14.04 server with 2GB memory and 2 cpu cores. It was deployed using mup
. However the CPU utilization is very high, htop
reports 2.72
load average.
meteor.js 0.82应用程序在Ubuntu 14.04服务器上运行,具有2GB内存和2个CPU内核。它是使用mup部署的。但是CPU利用率非常高,htop报告平均负载为2.72。
Question: How do I find out which part of the app is causing such a high CPU utilization? I used Kadira but it does not reveal anything taking up alot of CPU load afaik.
问题:如何找出应用程序的哪个部分导致如此高的CPU利用率?我使用了Kadira,但它没有透露任何占用大量CPU负载的东西。
Does Meteor only use a single core?
Meteor只使用一个核心吗?
1 个解决方案
#1
2
I had a similar problem before with Meteor 0.8.2-0.8.3. Here are what I have done to reduce the CPU usage, hope you may find it useful.
我之前遇到过与流星0.8.2-0.8.3类似的问题。以下是我为降低CPU使用率所做的工作,希望您发现它有用。
- double check your functions, ensure all function has proper
return
, and does properly catch errors - try to use a replicaSet and oplog mongo convert standalone to replica set
- write scripts to auto kill and resprawn a node process if it exceeds 100% cpu usage
- utilize multi-core capability by starting 2 processes (edit you have done already) and configure and setup load-balance and reverse proxy
- make sure to review your publish and subscription and limit what data to be sent to client (simply avoid something like
Collection.find();
)
仔细检查您的功能,确保所有功能都有正确的返回,并正确捕获错误
尝试使用replicaSet和oplog mongo将独立转换为副本集
如果节点进程超过100%的CPU使用率,则编写脚本以自动终止并重新绘制节点进程
通过启动2个进程(已经完成编辑)并配置和设置负载平衡和反向代理来利用多核功能
确保检查您的发布和订阅,并限制要发送给客户端的数据(只需避免像Collection.find();)
Personally I recommend Phusion Passenger, it makes deploying Meteor applications an ease, and I have used it for several projects without any major problems.
我个人推荐Phusion Passenger,它使得部署Meteor应用程序变得轻松,我已经将它用于几个项目而没有任何重大问题。
One more thing, avoid running the processes in root (or privilege user), you should be running your apps in another user like www-data. This is for obvious security reason.
还有一件事,避免在root(或特权用户)中运行进程,你应该在另一个用户运行你的应用程序,如www-data。这是出于明显的安全原因。
P.S. and multiple mongo processes showing in htop are threads under a master process, you can view it in tree mode by pressing F5
.
附:在htop中显示的多个mongo进程是主进程下的线程,您可以通过按F5以树模式查看它。
#1
2
I had a similar problem before with Meteor 0.8.2-0.8.3. Here are what I have done to reduce the CPU usage, hope you may find it useful.
我之前遇到过与流星0.8.2-0.8.3类似的问题。以下是我为降低CPU使用率所做的工作,希望您发现它有用。
- double check your functions, ensure all function has proper
return
, and does properly catch errors - try to use a replicaSet and oplog mongo convert standalone to replica set
- write scripts to auto kill and resprawn a node process if it exceeds 100% cpu usage
- utilize multi-core capability by starting 2 processes (edit you have done already) and configure and setup load-balance and reverse proxy
- make sure to review your publish and subscription and limit what data to be sent to client (simply avoid something like
Collection.find();
)
仔细检查您的功能,确保所有功能都有正确的返回,并正确捕获错误
尝试使用replicaSet和oplog mongo将独立转换为副本集
如果节点进程超过100%的CPU使用率,则编写脚本以自动终止并重新绘制节点进程
通过启动2个进程(已经完成编辑)并配置和设置负载平衡和反向代理来利用多核功能
确保检查您的发布和订阅,并限制要发送给客户端的数据(只需避免像Collection.find();)
Personally I recommend Phusion Passenger, it makes deploying Meteor applications an ease, and I have used it for several projects without any major problems.
我个人推荐Phusion Passenger,它使得部署Meteor应用程序变得轻松,我已经将它用于几个项目而没有任何重大问题。
One more thing, avoid running the processes in root (or privilege user), you should be running your apps in another user like www-data. This is for obvious security reason.
还有一件事,避免在root(或特权用户)中运行进程,你应该在另一个用户运行你的应用程序,如www-data。这是出于明显的安全原因。
P.S. and multiple mongo processes showing in htop are threads under a master process, you can view it in tree mode by pressing F5
.
附:在htop中显示的多个mongo进程是主进程下的线程,您可以通过按F5以树模式查看它。