0

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.

4

2 回答 2

0

因此可以想象,在那些不受 ansible 管理的服务器上设置了一个(或多个)配置。

从那里开始。

收集有关信息:

  • PHP版本
    • 和配置
  • Linux内核
    • 和配置(例如swappiness)
  • libc 版本
  • 网络服务器版本
    • 和配置

假设三台服务器具有相同数量的内存和相同的进程运行,任何差异只能源于这些参数。

您也可以尝试执行一个示例命令行脚本来查看内存分配异常是否也出现在那里。无论发生什么,你都会学到一些东西;如果它也出现在脚本中,那么通过 strace 或 Valgrind 一次运行 PHP 二进制文件的单个实例会更容易。

于 2020-03-20T16:05:22.613 回答
0

看来问题出在第三台服务器中的 php 配置上。显然,第 3 台服务器配置为使用 MPM 事件模块,而其他 2 台服务器配置为使用 MPM Prefork。当我将第三台服务器更改为使用 MPM Prefork 时,我看到内存消耗又回到了其他 2 台的水平。

我计划进一步研究这个问题并找出为什么其他 MPM 模块有如此不寻常的内存消耗。

注意,mpm 配置在这里找到:/etc/httpd/conf.modules.d/00-mpm.conf

于 2020-03-23T19:10:09.097 回答