0

I have a docker container based on php:7.2-apache-stretch running in kubernetes/rancher. The current k8s memory limit is excessively low, so users get errors and truncated pages when worker processes get oomkill'd. Since the httpd parent process isn't getting killed, my container doesn't die or restart, which I would see logs for. I was also surprised to not see any logs in the container's stdout/stderr when these processes get killed.

Before upping the ram limit to a more reasonable value, I was hoping to understand how to build logging/alerting around this condition.

Are there standards/best practices for monitoring/alerting on these memory events?

Potential options I've considered but haven't been able to figure out:

  1. Configure k8s/rancher to log oom-killer events somewhere (or learn where they are)
  2. Configure Apache parent process to die if a worker is killed by oomkiller
  3. Configure Apache to log to stderr when a worker process is killed.
  4. Configure Apache to run with a single process? Maybe the default apache mpm config is non-ideal for containerization.
  5. Switch to a different web server?
  6. Other ideas?
  • Rather than switching to a different web server, since clearly your issue is the php libraries, I would try to separate php from httpd, as in httpd reverse proxying to php-fpm instead of burdening apache with php libraries and then blaming the web server for "its incorrect behaviour". – Daniel Ferradal Aug 11 '20 at 09:41
  • Also mpm_event or worker work fine in containers, just that you are stuck with a "prefork" model when you use mod_php and thus loading php libraries inside apache httpd. – Daniel Ferradal Aug 11 '20 at 09:42
  • thanks @ezra-s. It looks like php-fpm uses a pool of child processes, which could potentially have the same issue if those processes get killed. Do you know how it handles one of these processes being killed? I suppose by adding a proxy I might be able to catch/log errors there. – Stephen Pierce Aug 11 '20 at 15:54

0 Answers0