Nyxynyx
Nyxynyx

Reputation: 63599

High CPU Utilization for Meteor.js

enter image description here

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.

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.

Does Meteor only use a single core?

enter image description here enter image description here enter image description here enter image description here

Upvotes: 1

Views: 2123

Answers (1)

Anzel
Anzel

Reputation: 20543

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.

  • 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();)

Personally I recommend Phusion Passenger, it makes deploying Meteor applications an ease, and I have used it for several projects without any major problems.

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.

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.

Upvotes: 2

Related Questions