linux - 为什么两个不同系统之间的 apache2 中每个进程使用的内存差异如此之大?

标签 linux ubuntu apache2 ram

我有一对 Ubuntu 专用服务器...
服务器1:

Ubuntu 16.04.7 (64 bits)
16GB RAM
8 Xeon CPU
Apache 2.4.18
MPM mode: prefork
服务器2:
Ubuntu server 20.04.2 (64 bits)
32GB RAM
8 Xeon CPU
2.4.41
MPM mode: event
在 Server1 上,每个 apache2 进程使用 7MB 到 18MB 的 RAM ...
ps axo 'user rss cmd' | grep apache | grep -v "\(root\|grep\|tomcat\)"
www-data 18232 /usr/sbin/apache2 -k start
www-data 11700 /usr/sbin/apache2 -k start
www-data 11276 /usr/sbin/apache2 -k start
www-data 10792 /usr/sbin/apache2 -k start
www-data 11216 /usr/sbin/apache2 -k start
www-data 11600 /usr/sbin/apache2 -k start
www-data 10336 /usr/sbin/apache2 -k start
www-data 11356 /usr/sbin/apache2 -k start
www-data 11348 /usr/sbin/apache2 -k start
www-data 10980 /usr/sbin/apache2 -k start
www-data 11316 /usr/sbin/apache2 -k start
www-data  6808 /usr/sbin/apache2 -k start
在 Server2 上,每个 apache2 进程使用 120MB 到 130MB 的 RAM ...
ps axo 'user rss cmd' | grep apache | grep -v "\(root\|grep\|tomcat\)"
www-data 120436 /usr/sbin/apache2 -k start
www-data 119784 /usr/sbin/apache2 -k start
www-data 128720 /usr/sbin/apache2 -k start
www-data 130208 /usr/sbin/apache2 -k start
为什么使用的内存差异如此之大?
在阅读了一些文档和谷歌之后,我想到了加载模块,但每个服务器之间没有太大区别......
服务器1
# apache2 -M                 
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 actions_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 auth_openidc_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 bw_module (shared)
 cgi_module (shared)
 dav_module (shared)
 dav_fs_module (shared)
 dav_lock_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 expires_module (shared)
 fcgid_module (shared)
 filter_module (shared)
 headers_module (shared)
 include_module (shared)
 mime_module (shared)
 mpm_prefork_module (shared)
 negotiation_module (shared)
 proxy_module (shared)
 proxy_balancer_module (shared)
 proxy_fcgi_module (shared)
 proxy_http_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 slotmem_shm_module (shared)
 socache_shmcb_module (shared)
 ssl_module (shared)
 status_module (shared)
 suexec_module (shared)
 userdir_module (shared)
服务器2
# apache2 -M
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 aclr_module (shared)
 actions_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 auth_openidc_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgid_module (shared)
 dav_module (shared)
 dav_fs_module (shared)
 dav_lock_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 fcgid_module (shared)
 filter_module (shared)
 headers_module (shared)
 include_module (shared)
 mime_module (shared)
 mpm_event_module (shared)
 negotiation_module (shared)
 proxy_module (shared)
 proxy_balancer_module (shared)
 proxy_fcgi_module (shared)
 proxy_http_module (shared)
 remoteip_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 security2_module (shared)
 setenvif_module (shared)
 slotmem_shm_module (shared)
 socache_shmcb_module (shared)
 ssl_module (shared)
 status_module (shared)
 suexec_module (shared)
 unique_id_module (shared)
 userdir_module (shared)
我已经在 Server2 上将 MPM 模式从 Event 更改为 Prefork,结果相同。
我还能检查什么来理解这种差异?

最佳答案

问题出在模块 security2 上。
启用模块(每个进程 120-160MB)...

# ps axo 'user rss cmd' | grep apache | grep -v "\(root\|grep\|tomcat\)"
www-data 121232 /usr/sbin/apache2 -k start
www-data 120596 /usr/sbin/apache2 -k start
www-data 156816 /usr/sbin/apache2 -k start
www-data 162668 /usr/sbin/apache2 -k start
禁用模块(每个进程 9-15MB)...
# a2dismod security2
Module security2 disabled.
To activate the new configuration, you need to run:
  systemctl restart apache2
# systemctl restart apache2
# ps axo 'user rss cmd' | grep apache | grep -v "\(root\|grep\|tomcat\)"
www-data 10340 /usr/sbin/apache2 -k start
www-data  9764 /usr/sbin/apache2 -k start
www-data 14164 /usr/sbin/apache2 -k start
www-data 14220 /usr/sbin/apache2 -k start
您可以在此处关注电子邮件对话:http://mail-archives.apache.org/mod_mbox/httpd-users/202105.mbox/%3CCAD41RFYjd3XcAEqopgVWKQUnsiv9NCHRLGTM0tEOD4Kg8%2B_2hA%40mail.gmail.com%3E

关于linux - 为什么两个不同系统之间的 apache2 中每个进程使用的内存差异如此之大?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67439771/

相关文章:

c - c Linux 中 system() 的替代方案,用于在 Linux 上执行终端命令

postgresql - 如何通过 Amazon EC2 将 postgresql 数据移动到 Ubuntu 上的另一个目录?

java - jdbc、tomcat、apache 和 mod-jk 错误 "No suitable driver"

http - 由于生产中的 STS 规则,开发站点重定向到 https

linux - 如何从apk版本命令返回的结果中去掉\n

python - python可以检测到它在哪个操作系统下运行吗?

java - 如何通过netbeans启用从Windows机器到Ubuntu机器的远程调试

regex - 如何在 Linux 中将正则表达式传递给 find 命令?

python - 无法在虚拟环境中运行 django wsgi

c - 如何打开覆盖现有内容的文件