1

On an ubuntu box with 4GB, I am running apache with some mpm + mysqld. Furthermore, there is a postfix, mongod and ocassionaly some imagemagick/convert processes active.

On 99% of the days, that's fine. However, sometimes (not at peak times, but e.g. at 3am in the morning - although backup process start few hours late) the server runs out of RAM. Then it's killing processes and unfortunately it's starting with apache and/or mysqld :-(

Do I have a chance to define which process is "important" or high-priority? E.g. i'd define 1) apache 2) mysql 3) postfix 4) convert 5) mongod <- as far as i know, mongod is very polite and will release ram for other applications if needed.

Btw. the system is not running out of memory because of ghost processes; i use some cleaner scripts which make sure that unused ram is recycled :-)

Thx

2 Answers 2

0

This is behavior determined by the kernel. When the kernel runs out of memory, it reacts poorly and kills the process using the most amount of memory. On the desktop, this can sometimes be the xserver, another poor choice to kill first. This shouldn't happen with adequate swap.

If your strategy was to go without a swap file in order to force the OS to use RAM, I suggest you instead have a swap file, and use the swappiness setting to make the OS use primarily RAM. Find out how to do that here: How do I configure swappiness?

10 is a typical aggressive value for swappiness. I found that with values less than 10, the OS seemed to prioritized unloading the swap over the actual running of programs. In other words, when I ran out of memory, things slowed down immensely. So maybe start with 10, or something close, and see how well it uses the RAM.

-1

Well, in System Monitor you can simply assign a priority via right-clicking a process and choosing change priority. If you don't have a GUI running, you should use the command renice, just check out the manpage.

3
  • Hi, Thanks for reply. Are you sure that ubuntu respects the nice level when shutting down a process to release required memory? I thought it was already "priorized" in this way and wonder if ubuntu is following the rules...
    – ledy
    Jun 18, 2012 at 11:08
  • @ledy Processes with lower nice levels are not necessarily more important; they're just intended to get more CPU time. For example, pulseaudio runs with a far lower nice level than init, but the consequences of killing init are almost always far more severe than then consequences of killing pulseaudio. Jun 18, 2012 at 11:23
  • @Eliah Kagan: Does the nice level only target the cpu behaviour? No effect when OS is killing because of low memory/ram available?
    – ledy
    Jun 18, 2012 at 12:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .