1

I have a node.js application on my EC2 instance. I am using pm2 to run the process. Everything here goes well but sometimes what happens is that the memory on the server gets exhausted.When this happens the mongodb connection closes and there remains no space to even save logs I guess.

Whenever this happens I have to ssh to server and clear the logs and then restart the mongodb service and then reload all pm2 processes. There is no option to increase the storage space on EC2.

I am currently running my production app on t2 large instance but still it goes out of memory.

halfer
  • 19,824
  • 17
  • 99
  • 186
Abhishek Dubey
  • 937
  • 8
  • 11
  • just try to fire "top" command and see which all processes are consuming the more memory and in cloud watch (in monitoring section ) try to see the CPU ultilization – karan sharma Jul 02 '18 at 09:06
  • and for the logs there is log rotation policy available, you can use that – karan sharma Jul 02 '18 at 09:07

1 Answers1

2

There are plenty of ways to increase storage space on EC2. See this stackoverflow issue to learn how. Increasing the storage space will just have the effect that it will take longer for your disk to get full. Eventually it will crash again.

I think you may be turning cause and effect around. What most likely happens is the following:

  1. Disk runs out of memory
  2. App stores everything in memory
  3. Memory gets full
  4. Crash

I would advise to install logrotate (Or whatever tool that provides log rotation policy) on your machine. This will fix your log increase issue.

ThomasVdBerge
  • 7,483
  • 4
  • 44
  • 62