I have a very slow home server (raspberry pi) with 700 MHz CPU. When I develop some sites, it sometimes happens that I input a large (5 MB) .jpg file into an image resizer (imagecreatefromjpeg(), imagecreatetruecolor(), imagecopy()) which causes the server to hang.
I’d say it’s processing the file, but even when I wait for minutes, it never ends.
The problem is that I cannot even access the shell to stop/restart apache2; the only solution is to power off the server completely.
I was wondering whether there’s any way to limit HW resources for apache2; for example if I could limit only 80% CPU usage for it, maybe I could still access the shell and stop it.
I tried setting the timeout and max_execution_time directives, but they don’t seem to stop apache2 from working infinitely and freezing the server.
Any ideas how to solve this?
I don’t think you can limit the cpu usage of apache from its own settings.
You can try using a separate app like cpulimit (see: how-to):
You can also try these to optimize the overall performance of your server.
Edit your /etc/apache2/apache2.conf and use these values:
Expand your swap in /etc/dphys-swapfile set:
Then run:
Overclock your raspberry (it’s safer than it sounds) here:
I use it at 950MHz. There is a higher option (1000MHz), but some people on the forum complained about SD corruption with that one.
You can also set the graphic memory to 16 in raspi-config memory_split if you do not use the graphical interface.