Bug 55000 - Memory usage per process doubles when Apache is compiled with --enable-pie
Summary: Memory usage per process doubles when Apache is compiled with --enable-pie
Status: RESOLVED LATER
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Core (show other bugs)
Version: 2.2.24
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: MassUpdate
Depends on:
Blocks:
 
Reported: 2013-05-21 20:44 UTC by darknovanick
Modified: 2018-11-07 21:08 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description darknovanick 2013-05-21 20:44:25 UTC
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.

The problem server is running CentOS (RedHat Enterprise clone) 5.9. gcc is version 4.1.2. php is 5.3.3 and I am using mod_php with Apache.

httpd is running in prefork mode.

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.

I am measuring httpd's memory usage with http://www.pixelbeat.org/scripts/ps_mem.py which takes into account shared memory. Slightly different but pretty close results can be found with the line:

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 }'

For test purposes, I have httpd configured with MaxClients 10 and MaxRequestsPerChild 0 so that the memory problem appears more quickly.

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.

I compiled 2.2.24 with:
./configure --prefix=/tmp/httpd-install --enable-pie --enable-mods-shared=all --enable-ssl --with-ssl

I let it run on my test URLs and after 1+ hours, it stabilizes on a memory usage of around 110 MB per process.

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:

./configure --prefix=/tmp/httpd-install --enable-mods-shared=all --enable-ssl --with-ssl 

And running with the same URLs in a similar way, stabilizes on a memory usage of around 60 MB per process.

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.

I have tried playing with the --enable-pie option on a debian system, and have not been able to see much difference.

On this redhat 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.

I have been researching the --enable-pie option and am at a loss as to why that would cause such a memory jump.

I also do not know if another PHP application, or running httpd without PHP, would see the same memory doubling or not.
Comment 1 William A. Rowe Jr. 2018-11-07 21:08:14 UTC
Please help us to refine our list of open and current defects; this is a mass update of old and inactive Bugzilla reports which reflect user error, already resolved defects, and still-existing defects in httpd.

As repeatedly announced, the Apache HTTP Server Project has discontinued all development and patch review of the 2.2.x series of releases. The final release 2.2.34 was published in July 2017, and no further evaluation of bug reports or security risks will be considered or published for 2.2.x releases. All reports older than 2.4.x have been updated to status RESOLVED/LATER; no further action is expected unless the report still applies to a current version of httpd.

If your report represented a question or confusion about how to use an httpd feature, an unexpected server behavior, problems building or installing httpd, or working with an external component (a third party module, browser etc.) we ask you to start by bringing your question to the User Support and Discussion mailing list, see [https://httpd.apache.org/lists.html#http-users] for details. Include a link to this Bugzilla report for completeness with your question.

If your report was clearly a defect in httpd or a feature request, we ask that you retest using a modern httpd release (2.4.33 or later) released in the past year. If it can be reproduced, please reopen this bug and change the Version field above to the httpd version you have reconfirmed with.

Your help in identifying defects or enhancements still applicable to the current httpd server software release is greatly appreciated.