You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Zaccone, Warren" <wz...@telcordia.com> on 2011/06/20 02:38:41 UTC

[users@httpd] What does Timeout in the httpd.conf file accomplish?

Running  multiple copies of this script concurrently brings httpd into a hang state, that it will not recover from without manually restarting the httpd server.

ab -n 300 -c 300 http://myserver/mysite/loop.php

<?php
/*  loop.php */

while (1) sleep (20);

?>
I have timeout set to 900 but it does not appear to be working.  What does timeout in the httpd.conf do?

Will the httpd.conf  timeout protect the server from such scripts or  is there something else.

I am configured using Prefork

settings are:

Timeout 900
MaxKeepAliveRequests 100
StartServers        5
MinSpareServers     5
MaxSpareServers     10
MaxClients          256
MaxRequestsPerChild   0

# pstack 22040 (root)
22040:  /usr/local/apache/bin/httpd -d /usr/local/apache -f /usr/local/apache/
feccc4a8 pollsys  (ffbfe388, 0, ffbfe3f0, 0)
fec67dc0 pselect  (ffbfe388, fed34660, fed34660, 0, ffbfe3f0, 0) + 1c8
fec68138 select   (0, 0, 0, 0, ffbfe458, 0) + a0
ff05f5bc apr_sleep (0, f4240, ffbfe554, 0, d0b78, 11176) + 4c
00048fa8 ap_wait_or_timeout (ffbfe554, ffbfe550, ffbfe5d8, d0b78, c5c00, c2800)
+ 60
00087530 ap_mpm_run (c5c00, c3800, ff, c5c00, c6000, c5c00) + 33c
0002e1e0 main     (d0b78, c0c00, c3000, c3000, ceb70, 0) + 784
0002d57c _start   (0, 0, 0, 0, 0, 0) + 5c

pstack of all 256 workers is :

  pstack 4851
4851:   /usr/local/apache/bin/httpd -d /usr/local/apache -f /usr/local/apache/
feccbad0 nanosleep (ffbfd8c0, ffbfd8b8)
fe63df54 zif_sleep (1, 1bfaa0, 0, 0, 0, ffbfda60) + 54
fe719330 zend_do_fcall_common_helper_SPEC (ffbfda78, 1, 0, 0, 18, 0) + 940
fe7188f8 execute  (1bf580, 1bf618, 1d, ffbfdb44, 4, fe7187ec) + 10c
fe6f8bbc zend_execute_scripts (8, 0, 3, ffbfdbb0, fe8a5ed0, ffbfe0f8) + d4
fe6b11e8 php_execute_script (0, fe851228, 6, 0, 70687000, 0) + 218
fe793064 php_handler (2cfbc0, 0, 2cfbc0, c2000, c32b0, 9) + 2cc
00041014 ap_run_handler (2cfbc0, 3b3b3b3b, 70687000, 80808080, ff00, 80808080)
+ 3c
00041490 ap_invoke_handler (165870, 96c00, 2cfbc0, ffbfe254, fe930028, 0) + b8
0006c310 ap_process_request (2cfbc0, 0, 4, 2cfbc0, 0, 0) + 160
00069478 ap_process_http_connection (2c9e40, 2c9ba8, 2c9ba8, fe, c3b10, eaf60)
+ 10c
000477b8 ap_run_process_connection (2c9e40, 2c9ba8, 2c9ba8, fe, 2c7bf0, 2cdb78)
+ 3c
00086ea4 child_main (0, 1, c6000, c5c00, 11177, c5c00) + 42c
00087108 make_child (86800, fe, 6, 0, d66d0, c5c00) + ec
00087b10 ap_mpm_run (c5c00, c3800, ee, c5c00, c6000, c5c00) + 91c
0002e1e0 main     (d0b78, c0c00, c3000, c3000, ceb70, 0) + 784
0002d57c _start   (0, 0, 0, 0, 0, 0) + 5c
#

RE: [users@httpd] What does Timeout in the httpd.conf file accomplish?

Posted by "Zaccone, Warren" <wz...@telcordia.com>.
the script is a silly trivial example of how  a more complex script with a loop that is not obvious could cause a major issue.
the scripts ran indefinitely despite the timeout.  the server had to manually restarted.





________________________________
From: Jeroen Geilman [jeroen@adaptr.nl]
Sent: Sunday, June 19, 2011 8:46 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] What does Timeout in the httpd.conf file accomplish?

On 06/20/2011 02:38 AM, Zaccone, Warren wrote:
Running  multiple copies of this script concurrently brings httpd into a hang state, that it will not recover from without manually restarting the httpd server.

ab -n 300 -c 300 http://myserver/mysite/loop.php

You're requesting a single URL 300 times concurrently.
This means that apache has to dedicate 300 threads at once to this purpose.
this is a trivial test case.

If you're not running worker, and your minspare is lower than 250 or so, it's going to take MINUTES to even get to number 300.

As documented, when many new (prefork) threads are being requested at once, apache will only  spawn one per second, to protect itself from attacks and runaway processes.
the point is not how the situation was produced, but rather why aren't the 256 workers that are running this script stoppe.  I know that I started more than 300.

<?php
/*  loop.php */

while (1) sleep (20);

?>

And the request does nothing for 20 seconds before returning.

What exactly are you testing here ?

reproducing fact. that a single user of my server can bring down the server with a simple script.  running it from the unix command prompt is not realistic, but it is realistic that an automated script from another server could be doing so.
I have timeout set to 900 but it does not appear to be working.  What does timeout in the httpd.conf do?


As documented, Timeout determines the maximum number of seconds that a single request may take.

I am afraid not - each of the copies of httpd running the above script ran indefinitely.

Will the httpd.conf  timeout protect the server from such scripts or  is there something else.

Yes, Timeout works on the HTTP level, so everything sent over HTTP is affected by it.

This means everything.



I am configured using Prefork

Then that apachebench run you show above is bloody stupid.
please Explain?



settings are:

Timeout 900
MaxKeepAliveRequests 100
StartServers        5
MinSpareServers     5
MaxSpareServers     10
MaxClients          256


You can't even SERVE 300 concurrent requests.


MaxRequestsPerChild   0

Ok, so you have given me some useful advice here, unintentionally.   this value should not be 0?


If you run PHP, this kills apache.
Eventually.


# pstack 22040 (root)

You have no idea what you are doing.
This was entirely unnecessary.    Why do you say this.   I am reproducing an ellusive situation with a trival test case.., there is no reason to get personal.    I thought this forum was a place people could ask silly questions and not be attacked.




--
J.


Re: [users@httpd] What does Timeout in the httpd.conf file accomplish?

Posted by Jeroen Geilman <je...@adaptr.nl>.
On 06/20/2011 02:38 AM, Zaccone, Warren wrote:
>
> Runningmultiple copies of this script concurrently brings httpd into a 
> hang state, that it will not recover from without manually restarting 
> the httpd server.
>
> ab-n 300 -c 300 http://myserver/mysite/loop.php
>

You're requesting a single URL 300 times concurrently.
This means that apache has to dedicate 300 threads at once to this purpose.

If you're not running worker, and your minspare is lower than 250 or so, 
it's going to take MINUTES to even get to number 300.

As documented, when many new (prefork) threads are being requested at 
once, apache will only  spawn one per second, to protect itself from 
attacks and runaway processes.


> <?php
>
> /* loop.php */
>
> while (1) sleep (20);
>
> ?>
>

And the request does nothing for 20 seconds before returning.

What exactly are you testing here ?


> I have timeout set to 900 but it does not appear to be working.What 
> does timeout in the httpd.conf do?
>


As documented, Timeout determines the maximum number of seconds that a 
single request may take.


> Will the httpd.conf  timeout protect the server from such scripts or  
> is there something else.
>

Yes, Timeout works on the HTTP level, so everything sent over HTTP is 
affected by it.

This means everything.


> I am configured using Prefork
>

Then that apachebench run you show above is bloody stupid.

> settings are:
>
> Timeout 900
>
> MaxKeepAliveRequests 100
>
> StartServers5
>
> MinSpareServers5
>
> MaxSpareServers10
>
> MaxClients256
>


You can't even SERVE 300 concurrent requests.


> MaxRequestsPerChild  0
>

If you run PHP, this kills apache.
Eventually.

> # pstack 22040 (root)
>

You have no idea what you are doing.


-- 
J.


Re: [users@httpd] What does Timeout in the httpd.conf file accomplish?

Posted by Peter Horn <pe...@bigpond.com>.
On 06:59, Eric Covener wrote:
> On Mon, Jun 20, 2011 at 9:26 AM, Zaccone, Warren<wz...@telcordia.com>  wrote:
>> yes. so I am I.  The default setting is 30 seconds however pstack shows all 256 children running this script indefinitely - until I stop and restart httpd.
>>
>> This statement in the php doc is leading me to believe the Timeout directive will override:
>>
>> " Your web server can have other timeout configurations that may also interrupt PHP execution. Apache has a Timeout directive and IIS has a CGI timeout function. Both default to 300 seconds. See your web server documentation for specific details."
> FWIW, if you were running PHP as CGI, and not trickling back some
> input in that loop, Apache's CGI module would give up based on the
> Timeout.  But since you run mod_php, nobody but PHP is watching the
> clock.
>
I might be able to shed a little light into this dark corner. (I found 
this out the hard way in a different context.*) Under Linux and similar 
OSs (but NOT windows), the PHP time limit applies to *User CPU* time 
only. It does not include system CPU time or any of the myriad varieties 
of wait time. So OP's loop around sleep will take a looooong time (but 
not literally forever) to eat up 300 secs or whatever of user cpu.

* I got bitten by the converse - a PHP maintenance script in Drupal was 
getting timed out (wallclock time) on a Windows server because of I/O 
wait time.

HTH
Peter


---------------------------------------------------------------------
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] What does Timeout in the httpd.conf file accomplish?

Posted by Eric Covener <co...@gmail.com>.
On Mon, Jun 20, 2011 at 9:26 AM, Zaccone, Warren <wz...@telcordia.com> wrote:
> yes. so I am I.  The default setting is 30 seconds however pstack shows all 256 children running this script indefinitely - until I stop and restart httpd.
>
> This statement in the php doc is leading me to believe the Timeout directive will override:
>
> " Your web server can have other timeout configurations that may also interrupt PHP execution. Apache has a Timeout directive and IIS has a CGI timeout function. Both default to 300 seconds. See your web server documentation for specific details. "

FWIW, if you were running PHP as CGI, and not trickling back some
input in that loop, Apache's CGI module would give up based on the
Timeout.  But since you run mod_php, nobody but PHP is watching the
clock.

---------------------------------------------------------------------
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] What does Timeout in the httpd.conf file accomplish?

Posted by "Zaccone, Warren" <wz...@telcordia.com>.
yes. so I am I.  The default setting is 30 seconds however pstack shows all 256 children running this script indefinitely - until I stop and restart httpd. 

This statement in the php doc is leading me to believe the Timeout directive will override:

" Your web server can have other timeout configurations that may also interrupt PHP execution. Apache has a Timeout directive and IIS has a CGI timeout function. Both default to 300 seconds. See your web server documentation for specific details. "

I will pursue with php instead of httpd now. 

-----Original Message-----
From: Igor Galić [mailto:i.galic@brainsware.org] 
Sent: Monday, June 20, 2011 9:11 AM
To: users@httpd.apache.org
Subject: Re: [users@httpd] What does Timeout in the httpd.conf file accomplish?



----- Original Message -----
> .  thank you very much,  I understand
>  I will make certain the max excecution time for a script has an
>  appropriate default value within the intepretor.

I'm confused as to how this can run for longer than
http://php.net/manual/en/info.configuration.php#ini.max-execution-time

i

  
> ________________________________________
> From: Eric Covener [covener@gmail.com]
> Sent: Sunday, June 19, 2011 8:41 PM
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] What does Timeout in the httpd.conf file
> accomplish?
> 
> > I have timeout set to 900 but it does not appear to be working.
> >  What does
> > timeout in the httpd.conf do?
> 
> http://httpd.apache.org/docs/current/mod/core.html#timeout
> 
> > Will the httpd.conf  timeout protect the server from such scripts
> > or  is
> > there something else.
> 
> Not malicious ones, perhaps something in the interpreter (PHP)
> itself?
> 
> ---------------------------------------------------------------------
> 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
> ---------------------------------------------------------------------
> 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/

---------------------------------------------------------------------
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] What does Timeout in the httpd.conf file accomplish?

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

----- Original Message -----
> .  thank you very much,  I understand
>  I will make certain the max excecution time for a script has an
>  appropriate default value within the intepretor.

I'm confused as to how this can run for longer than
http://php.net/manual/en/info.configuration.php#ini.max-execution-time

i

  
> ________________________________________
> From: Eric Covener [covener@gmail.com]
> Sent: Sunday, June 19, 2011 8:41 PM
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] What does Timeout in the httpd.conf file
> accomplish?
> 
> > I have timeout set to 900 but it does not appear to be working.
> >  What does
> > timeout in the httpd.conf do?
> 
> http://httpd.apache.org/docs/current/mod/core.html#timeout
> 
> > Will the httpd.conf  timeout protect the server from such scripts
> > or  is
> > there something else.
> 
> Not malicious ones, perhaps something in the interpreter (PHP)
> itself?
> 
> ---------------------------------------------------------------------
> 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
> ---------------------------------------------------------------------
> 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/

---------------------------------------------------------------------
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] What does Timeout in the httpd.conf file accomplish?

Posted by "Zaccone, Warren" <wz...@telcordia.com>.
 .  thank you very much,  I understand 
 I will make certain the max excecution time for a script has an appropriate default value within the intepretor.    


 
________________________________________
From: Eric Covener [covener@gmail.com]
Sent: Sunday, June 19, 2011 8:41 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] What does Timeout in the httpd.conf file accomplish?

> I have timeout set to 900 but it does not appear to be working.  What does
> timeout in the httpd.conf do?

http://httpd.apache.org/docs/current/mod/core.html#timeout

> Will the httpd.conf  timeout protect the server from such scripts or  is
> there something else.

Not malicious ones, perhaps something in the interpreter (PHP) itself?

---------------------------------------------------------------------
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
---------------------------------------------------------------------
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] What does Timeout in the httpd.conf file accomplish?

Posted by Eric Covener <co...@gmail.com>.
> I have timeout set to 900 but it does not appear to be working.  What does
> timeout in the httpd.conf do?

http://httpd.apache.org/docs/current/mod/core.html#timeout

> Will the httpd.conf  timeout protect the server from such scripts or  is
> there something else.

Not malicious ones, perhaps something in the interpreter (PHP) itself?

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