tableflip / guvnor

A node process manager that isn't spanners all the way down
MIT License
430 stars 37 forks source link

Automatic restarts if process uses too much CPU, RAM, … #53

Closed goloroden closed 9 years ago

goloroden commented 9 years ago

As guvnor monitors the processes it runs anyway, it would be great if you could assign limits for CPU usage, RAM usage, …

If a process uses more than these limits, it should be restarted.

E.g.: You know that you have a memory leak in your application, but you can't find it. A workaround may be to restart it every time if it uses more than 500 MBytes of memory. Or if it ran longer than 60 minutes. Or ... ;-)

What do you think about this?

achingbrain commented 9 years ago

I'm not sure this is the right place to do this. If you want to restrict processes on RAM/CPU usage, you should probably virtualise the whole thing using Docker or similar because that will restrict usage at the kernel level which is a lot better than trying to get a userland process to do it.

randomsock commented 9 years ago

-1: max cpu/memory restarts

This proved to be a real pain in pm2 because it kills and restarts the entire cluster, regardless of whether any process is actually doing something! Not sure which is worse: the service gradually degrading through starvation, or random but frequent and embarrassing service failures - in the end we turned the limit off.

If you could guarantee to only do it on a per-process basis when it is truly quiesced then I'd consider it, but a better systemic approach would be docker/similar, as you said.

achingbrain commented 9 years ago

Docker would kill the whole cluster as well so it's not much of an improvement.

It sounds harsh but you're better off fixing the leak in the problematic app.