9

I am running simple Meteor app on basic (512GB) DigitalOcean droplet. Once in a while Meteor simply crashes with this error message:

enter image description here

Out of memory: Kill process 9682 (node) ...
...
=> Exited from signal: SIGKILL
FATAL ERROR: JS Allocation failed - process out of memory

What is wrong? This is really simple app and it could not spend all the memory.

Paul
  • 26,170
  • 12
  • 85
  • 119
Marek
  • 2,608
  • 4
  • 25
  • 32
  • 1
    I really like this question title :] – eddie_cat Sep 12 '14 at 21:48
  • are you running in a meteor dev mode? – imslavko Sep 12 '14 at 21:53
  • I run it like this `meteor --port 80`. – Marek Sep 12 '14 at 22:02
  • It is saying the droplet ran out of memory. This could be due to other code, like the web server and database server, if you are running the whole stack on one droplet... Also the 512MB is the smallest droplet, $5/mo. Maybe try the $10/mo droplet that has 1GB? The hosting service Modulus.io is $15/mo, avoids maintaining the full stack yourself, and has been reliable for me. – Paul Sep 13 '14 at 03:30

6 Answers6

18

You can keep the smallest Droplet if you want. I had the same problem on my $5/mo DigitalOcean Droplet, 512MB RAM and 20 GB SSD. I did not upgrade but instead implemented swap as follows:

Create and enable the swap file using the dd command:

sudo dd if=/dev/zero of=/swapfile bs=1024 count=256k

“of=/swapfile” designates the file’s name. In this case the name is swapfile.

Next prepare the swap file by creating a linux swap area:

sudo mkswap /swapfile

The results display:

Setting up swapspace version 1, size = 262140 KiB
no label, UUID=103c4545-5fc5-47f3-a8b3-dfbdb64fd7eb

Finish up by activating the swap file:

sudo swapon /swapfile

You will then be able to see the new swap file when you view the swap summary.

swapon -s
Filename                Type        Size    Used    Priority
/swapfile                               file        262140  0   -1

This file will last on the virtual private server until the machine reboots. You can ensure that the swap is permanent by adding it to the fstab file.

Open up the file:

sudo nano /etc/fstab

Paste in the following line:

 /swapfile       none    swap    sw      0       0 

Swappiness in the file should be set to 10. Skipping this step may cause both poor performance, whereas setting it to 10 will cause swap to act as an emergency buffer, preventing out-of-memory crashes.

You can do this with the following commands:

echo 10 | sudo tee /proc/sys/vm/swappiness
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
To prevent the file from being world-readable, you should set up the correct permissions on the swap file:

sudo chown root:root /swapfile 
sudo chmod 0600 /swapfile
Community
  • 1
  • 1
FullStack
  • 5,902
  • 4
  • 43
  • 77
  • 2
    YES!!! Though doesn't it make sense to use more than 262mb for swap, or am I missing something here? – krivar Nov 04 '14 at 10:09
  • 1
    Just a heads up for anyone looking to use this answer: [YMMV](http://stackoverflow.com/questions/27329103/mup-deploy-killed-on-do-droplet-but-no-errors-in-logs) – FullStack Dec 07 '14 at 10:24
5

I was able to fix this issue by using more swap space than initially specified (more than 256mb) to 1GB.

To resize your swap space on Ubuntu to 1Gb:

sudo swapoff -a

sudo dd if=/dev/zero of=/swapfile bs=1M count=1024

sudo mkswap /swapfile

sudo swapon /swapfile
Milean
  • 878
  • 9
  • 16
3

You can try setting up a swap file for your DigitalOcean droplet.

DigitalOcean made an excellent guide on how to do this. You can find it here:

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

nilsi
  • 10,351
  • 10
  • 67
  • 79
1

I found the problem.

https://github.com/joyent/node/wiki/FAQ#what-is-the-memory-limit-on-a-node-process

I used only 512mb of RAM for 64-bit system. But this is not recommended for node process.

Marek
  • 2,608
  • 4
  • 25
  • 32
  • This repository has been archived by the owner. It is now read-only. – Yajairo87 Nov 19 '17 at 22:59
  • For the future: **Q:** I'm experiencing reliability/memory spiking issues on a low-memory system, what's going on? **A:** By default, `--max_old_space_size` (which controls the upper limit of the V8 heap) is ~1.5GB. If your system has less memory than that, you will need to explicitly set this option to the appropriate amount of memory available to that process. For example, `--max_old_space_size=128` will allow 128MB for that process. – Marek Nov 20 '17 at 20:40
0

I believe it may be related to an issue meteor may be having. Check out the comment showing the cpu usage in this github issue. https://github.com/meteor/meteor/issues/2536#issuecomment-55295490

Chad_Martinson
  • 84
  • 1
  • 1
  • 8
0

In response to Marek's answer,

I'm running a Meanjs app on Digital Ocean and while everything worked fine locally and when I tested my live app alone, as soon as a second user logged on it would run out of memory and crash.

Instead of trying the whole swap thing, I just upgraded from $5/mo for 512mb of RAM to $10/mo with 1G and so far I've got it up to 6 machines with multiple Chrome and Firefox browsers accessing it simultaneously just fine.

gravmod64
  • 11
  • 3