You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Enrico Daga <en...@gmail.com> on 2011/12/12 12:17:11 UTC

[users@httpd] RAM problem with apache and PHP on default centos configuration

Hi all,

I send this mail to both httpd and php lists.
I experienced the following problem running php scripts on httpd.
The RAM fills gradually until the system starts swapping, then, if I
don't restart the server, swap fills and everything goes down.
After some try/check tests, I realized that the memory used by a
single request is never released when the process is complete. This
makes the RAM to be gradually filled.
I thought in the beginning was a problem with the php application and
circular references on objects (I found some posts about this) then I
tried with a simple script (just populating a single array) but the
problem still occurs.
Our production environments are on Centos 4.9 - we have some legacy
applications that prevented us to upgrade the servers before.
For this sake I tried on fresh systems and more recent versions, and
experienced the same problem on Centos 4.9, 5.5 / PHP 5.1.6 and Centos
6 / PHP 5.3.6, with distributed packages for both httpd and php and
default configuration. Httpd uses the Prefork MPM module.
I also noticed that this _do not_ happen on Ubuntu 11.10 server. I had
a look at the configuration of both httpd and php, but in both cases
(Centos and Ubuntu) I could not noticed a difference on parameters
regarding memory usage.

Since this is the first time we run PHP applications on our httpd
servers I guess there is some configuration I should modify to have
the system behave correctly (free the memory when it is not needed).
The only workaround would be to move the MaxRequestsPerChild parameter
to 1, then killing the sub-process that hold the request, but I don't
believe this is the right solution.
Finally, I am not so sure that the issue I describe here belong to the
httpd or php lists, in this case please apologies, I would be very
happy if you can point me to a red-hat list (found a lot of lists, but
no sure which is related to httpd/php issues).

Thank you very much for any hint.

Best regards,
Enrico



-- 
Enrico Daga

--
http://www.enridaga.net
skype: enri-pan

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RAM problem with apache and PHP on default centos configuration

Posted by Enrico Daga <en...@gmail.com>.
Thank you all for your hints.
The problem was a misconfiguration, and seems to be solved reducing
the number of child processes and adjusting MaxRequstPerChild
parameter.

We will try also with mod_fcgid.
Do you know any trade off with respect to mod_php for developers
(differences in env variables, for example)?

Enrico

2011/12/14 Igor Galić <i....@brainsware.org>:
>
>
> ----- Original Message -----
>> On 12/12/2011 12:17, Enrico Daga wrote:
>> > Hi all,
>> >
>> > I send this mail to both httpd and php lists.
>> > I experienced the following problem running php scripts on httpd.
>> > The RAM fills gradually until the system starts swapping, then, if
>> > I
>> > don't restart the server, swap fills and everything goes down.
>> > After some try/check tests, I realized that the memory used by a
>> > single request is never released when the process is complete. This
>> > makes the RAM to be gradually filled.
>> > I thought in the beginning was a problem with the php application
>> > and
>> > circular references on objects (I found some posts about this) then
>> > I
>> > tried with a simple script (just populating a single array) but the
>> > problem still occurs.
>> > Our production environments are on Centos 4.9 - we have some legacy
>> > applications that prevented us to upgrade the servers before.
>> > For this sake I tried on fresh systems and more recent versions,
>> > and
>> > experienced the same problem on Centos 4.9, 5.5 / PHP 5.1.6 and
>> > Centos
>> > 6 / PHP 5.3.6, with distributed packages for both httpd and php and
>> > default configuration. Httpd uses the Prefork MPM module.
>> > I also noticed that this _do not_ happen on Ubuntu 11.10 server. I
>> > had
>> > a look at the configuration of both httpd and php, but in both
>> > cases
>> > (Centos and Ubuntu) I could not noticed a difference on parameters
>> > regarding memory usage.
>> >
>> > Since this is the first time we run PHP applications on our httpd
>> > servers I guess there is some configuration I should modify to have
>> > the system behave correctly (free the memory when it is not
>> > needed).
>> > The only workaround would be to move the MaxRequestsPerChild
>> > parameter
>> > to 1, then killing the sub-process that hold the request, but I
>> > don't
>> > believe this is the right solution.
>> > Finally, I am not so sure that the issue I describe here belong to
>> > the
>> > httpd or php lists, in this case please apologies, I would be very
>> > happy if you can point me to a red-hat list (found a lot of lists,
>> > but
>> > no sure which is related to httpd/php issues).
>> >
>> > Thank you very much for any hint.
>> >
>> > Best regards,
>> > Enrico
>> >
>>
>> Attach your configs when asking help, to have better performance
>> (memory/cpu
>> usage) dont use mod_php, instead try running php as cgi application
>> (cgid).
>
> or rather, mod_fcgid
>
>> --
>> Simone Caruso
>> IT Consultant
>> +39 349 65 90 805
>>
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP Server
>> Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>
> --
> Igor Galić
>
> Tel: +43 (0) 664 886 22 883
> Mail: i.galic@brainsware.org
> URL: http://brainsware.org/
> GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE
>



-- 
Enrico Daga

--
http://www.enridaga.net
skype: enri-pan

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RAM problem with apache and PHP on default centos configuration

Posted by Igor Galić <i....@brainsware.org>.

----- Original Message -----
> On 12/12/2011 12:17, Enrico Daga wrote:
> > Hi all,
> > 
> > I send this mail to both httpd and php lists.
> > I experienced the following problem running php scripts on httpd.
> > The RAM fills gradually until the system starts swapping, then, if
> > I
> > don't restart the server, swap fills and everything goes down.
> > After some try/check tests, I realized that the memory used by a
> > single request is never released when the process is complete. This
> > makes the RAM to be gradually filled.
> > I thought in the beginning was a problem with the php application
> > and
> > circular references on objects (I found some posts about this) then
> > I
> > tried with a simple script (just populating a single array) but the
> > problem still occurs.
> > Our production environments are on Centos 4.9 - we have some legacy
> > applications that prevented us to upgrade the servers before.
> > For this sake I tried on fresh systems and more recent versions,
> > and
> > experienced the same problem on Centos 4.9, 5.5 / PHP 5.1.6 and
> > Centos
> > 6 / PHP 5.3.6, with distributed packages for both httpd and php and
> > default configuration. Httpd uses the Prefork MPM module.
> > I also noticed that this _do not_ happen on Ubuntu 11.10 server. I
> > had
> > a look at the configuration of both httpd and php, but in both
> > cases
> > (Centos and Ubuntu) I could not noticed a difference on parameters
> > regarding memory usage.
> > 
> > Since this is the first time we run PHP applications on our httpd
> > servers I guess there is some configuration I should modify to have
> > the system behave correctly (free the memory when it is not
> > needed).
> > The only workaround would be to move the MaxRequestsPerChild
> > parameter
> > to 1, then killing the sub-process that hold the request, but I
> > don't
> > believe this is the right solution.
> > Finally, I am not so sure that the issue I describe here belong to
> > the
> > httpd or php lists, in this case please apologies, I would be very
> > happy if you can point me to a red-hat list (found a lot of lists,
> > but
> > no sure which is related to httpd/php issues).
> > 
> > Thank you very much for any hint.
> > 
> > Best regards,
> > Enrico
> >
> 
> Attach your configs when asking help, to have better performance
> (memory/cpu
> usage) dont use mod_php, instead try running php as cgi application
> (cgid).

or rather, mod_fcgid

> --
> Simone Caruso
> IT Consultant
> +39 349 65 90 805
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RAM problem with apache and PHP on default centos configuration

Posted by Simone Caruso <in...@simonecaruso.com>.
On 12/12/2011 12:17, Enrico Daga wrote:
> Hi all,
> 
> I send this mail to both httpd and php lists.
> I experienced the following problem running php scripts on httpd.
> The RAM fills gradually until the system starts swapping, then, if I
> don't restart the server, swap fills and everything goes down.
> After some try/check tests, I realized that the memory used by a
> single request is never released when the process is complete. This
> makes the RAM to be gradually filled.
> I thought in the beginning was a problem with the php application and
> circular references on objects (I found some posts about this) then I
> tried with a simple script (just populating a single array) but the
> problem still occurs.
> Our production environments are on Centos 4.9 - we have some legacy
> applications that prevented us to upgrade the servers before.
> For this sake I tried on fresh systems and more recent versions, and
> experienced the same problem on Centos 4.9, 5.5 / PHP 5.1.6 and Centos
> 6 / PHP 5.3.6, with distributed packages for both httpd and php and
> default configuration. Httpd uses the Prefork MPM module.
> I also noticed that this _do not_ happen on Ubuntu 11.10 server. I had
> a look at the configuration of both httpd and php, but in both cases
> (Centos and Ubuntu) I could not noticed a difference on parameters
> regarding memory usage.
> 
> Since this is the first time we run PHP applications on our httpd
> servers I guess there is some configuration I should modify to have
> the system behave correctly (free the memory when it is not needed).
> The only workaround would be to move the MaxRequestsPerChild parameter
> to 1, then killing the sub-process that hold the request, but I don't
> believe this is the right solution.
> Finally, I am not so sure that the issue I describe here belong to the
> httpd or php lists, in this case please apologies, I would be very
> happy if you can point me to a red-hat list (found a lot of lists, but
> no sure which is related to httpd/php issues).
> 
> Thank you very much for any hint.
> 
> Best regards,
> Enrico
>

Attach your configs when asking help, to have better performance (memory/cpu
usage) dont use mod_php, instead try running php as cgi application (cgid).


-- 
Simone Caruso
IT Consultant
+39 349 65 90 805

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org