Consider a system with limited memory, like a smallish VPS. Suppose there are a handful of processes that need to stay alive, and one process "P" that would be nice to have around, but is not strictly necessary. What I'd like do is keep P around under times of low activity, but when activity picks up beyond a certain threshold, kill off P until activity lowers again, at which time I want P to come back. I'm not sure yet what I'd like "activity" to mean, but it could be any of: memory usage, swap usage, server load values.

I'm already using Monit, so it would be good if this could be accomplished with Monit. Bear in mind that I don't mean process memory usage, I mean overall system load. I don't have to use Monit for this, though, if something else will do the job.

  • 2
    Can't you just provide enough swap, renice process P to have a lower priority, and just the kernel take care of all this? – cjc Jan 31 '12 at 18:44
  • I'll give that a try. – Pistos Jan 31 '12 at 18:56

Like cjc said, the best way around this would be to provide enough swap to keep all processes running.

If you have many services you want to keep available (but not necessarily alive/running) you might think about inetd-ing them. Then they will be started only when somebody actually connects to a specific port on server. The downside: not all protocols have inetd implementations.

| improve this answer | |

Rather an old question but my answer to a similar question covers this.

Short version: you can use the STOP and CONT signals to pause and resume most memory-intensive processes, and there's an automated tool that does this for you when server is thrashing.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.