Quantcast
Channel: CentOS Bug Tracker - Issues
Viewing all articles
Browse latest Browse all 19115

0006478: Memory usage per process doubles when Apache httpd is compiled with --enable-pie

$
0
0
I've been trying to track down why the same web pages running on one server use far less memory than another server. This process has lead me to eventually discover how a difference in how Apache is compiled has made a huge difference.<br /> <br /> The problem server is running CentOS 5.9. gcc is version 4.1.2. php is 5.3.3 and I am using mod_php with Apache.<br /> <br /> httpd is running in prefork mode.<br /> <br /> My web application is Magento, which is a PHP application. I am running APC along with that. I have a test script that throws several thousands of URLs at the server.<br /> <br /> I am measuring httpd's memory usage with <a href="http://www.pixelbeat.org/scripts/ps_mem.py">http://www.pixelbeat.org/scripts/ps_mem.py</a> [<a href="http://www.pixelbeat.org/scripts/ps_mem.py" target="_blank">^</a>] which takes into account shared memory. Slightly different but pretty close results can be found with the line:<br /> <br /> ps -ef | grep httpd | grep -v ^root | awk '{ print $2 '} | xargs pmap -d | grep ^mapped: | awk '{ print $4 }' | cut -dK -f1 | awk '{ SUM += $1} END { print SUM/NR }'<br /> <br /> For test purposes, I have httpd configured with MaxClients 10 and MaxRequestsPerChild 0 so that the memory problem appears more quickly.<br /> <br /> I first noticed this problem with CentOS's stock httpd, which is a patched version of 2.2.3, but I have reproduced it with 2.2.24 to eliminate the possibility that it has already been fixed.<br /> <br /> I compiled 2.2.24 with:<br /> ./configure --prefix=/tmp/httpd-install --enable-pie --enable-mods-shared=all --enable-ssl --with-ssl<br /> <br /> I let it run on my test URLs and after 1+ hours, it stabilizes on a memory usage of around 110 MB per process.<br /> <br /> At first I thought there was a problem with PHP, but further investigation found that PHP's memory usage was a small fraction of this usage per child. I started changing configure options and eventually found that compiling 2.2.24 with:<br /> <br /> ./configure --prefix=/tmp/httpd-install --enable-mods-shared=all --enable-ssl --with-ssl <br /> <br /> And running with the same URLs in a similar way, stabilizes on a memory usage of around 60 MB per process.<br /> <br /> This is 100% reproducible on this system, I have tried 2.2.3, 2.2.22 and 2.2.24. These particular figures come from a test that didn't have any non-Apache-provided modules enabled except for mod_php.<br /> <br /> I have tried playing with the --enable-pie option on a debian system, and have not been able to see much difference.<br /> <br /> On this CentOS system, adding the --enable-pie option causes usage to about double, which is huge. On my actual production box, there can be over 100 child processes, and having each one with double the memory usage is a big problem.<br /> <br /> I have been researching the --enable-pie option and am at a loss as to why that would cause such a memory jump.<br /> <br /> I also do not know if another PHP application, or running httpd without PHP, would see the same memory doubling or not.

Viewing all articles
Browse latest Browse all 19115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>