phpamazon-ec2php-7memory-consumption

Unusual PHP Memory Consumption


I have 3 Apache/PHP7 servers running behind a load balancer. 2 of the 3 servers have been running without issue for several years. The third server (the newest server), however, has a PHP memory consumption issue.

While monitoring the servers in real time, I have noticed that the same call (example: /user/login) will require 10x more memory for the 3rd server than the other 2. Example: 18%MEM vs 1.2%MEM

All 3 servers are currently built and managed by ansible, so all 3 configurations should be exactly the same. However, the 2 servers that work as expected, existed before I started using ansible, so its conceivable that there is a config (or configs) set on those servers that is not managed by ansible.

All 3 servers run the exact same code base. All 3 servers are currently running in production.

The 3rd server has been rebuilt (completely new VM) several times, but always has the same exact issue as before.

I have run out of ideas and I would appreciate any help.

Note: I have tried memory tracing tools, but I have had a hard time getting them up and running in production as they are relatively invasive.


Solution

  • It appears the issue was from the php configuration in the 3rd server. Apparently the 3rd server was configured to use the MPM Event module while the other 2 servers were configured to use MPM Prefork. When I changed the 3rd server to use MPM Prefork, I saw the memory consumption go back down to the level of the other 2.

    I plan to look into the issue further and figure out why the other MPM module had such unusual memory consumption.

    Note, mpm configuration is found here: /etc/httpd/conf.modules.d/00-mpm.conf