We have a Dockerized environment for our clients so that each customer gets his own container to host his website. Each container usually runs on the php:7
image so we're speaking about Apache 2.4
using mpm_prefork
. Each container has a memory limit of 256Mb.
Now should any container be compromised for some reason, using the default Apache settings, it spawns lots of child processes eating essentially entire machine's RAM. That happens, because, apparently, total child process memory usage doesn't count towards the limit.
I'd like to prevent Apache from spawning child processes at all. So if the container is hacked, it will reach its memory limit and get killed by Docker.
I tried with:
StartServers 1
MinSpareServers 1
MaxSpareServers 1
ServerLimit 1
MaxClients 1
MaxRequestsPerChild 4000
But the performance was terrible, basic Drupal site with multiple CSS/script assets was loading for almost 60 seconds.
Is it possible to force Apache to use only one process and keep at least some performance? Sites are small and don't get a lot traffic so we don't care much, but the site should load fast for a single user at least.