Apache process swapping when idle

Hi There,

This is my first time posting to the forum, so I hope I've posted in the correct place.

I have an issue where Apache24 and some perl fastcgi processes, on a FreeBSD 10.3 install, go into swap when the system is idle. i.e. When no one has logged onto the web app in a few hours or days.
I understand that idle processes would be put into swap after some time, regardless of the amount of free or inactive memory, the problem though is that when a user attempts to logon to the web app, it takes forever to load and in some cases the web front-end times out and gives an error as apache and its' relevant processes are being pulled out of swap, in some cases it stays in swap until it's used continuously for a few minutes.
We don't have this issue of course on installs that have high usage and memory isn't an issue as we have low usage installs that this occurs on with anything from 16GB - 128GB of Memory.

Is there any steps that I can take to prevent these processes from going into swap if idle?
Currently I have a cronjob to restart the apache server every few hours to try and keep it from swapping out, however this may be an issue as it may cause issues if someone is actively using the web app at the time of the restart.
 
Instead of restarting you could run ab(1) at regular intervals. We mainly use the tool to warmup the caches before putting a server back online but it could also be used for this.
 
Thanks for the response, it's actually given me an idea to cron a script that queries the web app so it keeps the processes alive.
 
Maybe you should have a look at sysutils/monit: it can check information about your processes, request URLs, email you if something is wrong (like too much resources usage, too slow to respond), restart a crashed process,...
 
Back
Top