apache - Request not waiting PHP long process, returning 503 Service unavailable -


i wanted test max_execution_time setting using ini_set function php. setup simple test create infinite loop make sure timeout.

here code

test.php <?php             ini_set('max_execution_time', 300);    echo "hello world";    //for(;;); commented, see history    sleep(100);  ?> 

this code work nicely on windows machine running on top xampp. after 5 minutes, show hello world , fatal error exceeding time out.

then move code vps running ubuntu , apache. open web page browser. but, after 1 minute, browser shows

error code: 503 service unavailable network error  communication error occurred: "operation timed out" web server may down, busy, or experiencing other problems preventing responding requests. may wish try again @ later time. 

it doesn't wait 5 minutes. , consistently error after 1 minute. in error log, apache write fatal error exceeding time after 5 minutes.

so, in opinion, request cancelled before php script done.

i use default setting on apache2.conf additional virtual host

apache2.conf (additional only) <directory /var/www/mysite.com/public>     options followsymlinks     allowoverride </directory>  mysite.virtualhost.conf  <virtualhost virtualhost.mysite.com:80>     # servername directive sets request scheme, hostname , port     # server uses identify itself. used when creating     # redirection urls. in context of virtual hosts, servername     # specifies hostname must appear in request's host: header     # match virtual host. default virtual host (this file)     # value not decisive used last resort host regardless.     # however, must set further virtual host explicitly.     serveradmin admin@mysite.com     servername virtualhost.mysite.com     serveralias virtualhost.mysite.com     documentroot /var/www/mysite.com/public      # available loglevels: trace8, ..., trace1, debug, info, notice, warn,     # error, crit, alert, emerg.     # possible configure loglevel particular     # modules, e.g.     #loglevel info ssl:warn      errorlog ${apache_log_dir}/error.log     customlog ${apache_log_dir}/access.log combined </virtualhost> 

php.ini file

php.ini safe_mode = off max_execution_time = 1200 

so, config miss here? think there wrong in apache config don't know part.

update

after looking @ process running, apache process running infinite loop consuming 99% of cpu. why happening? using strace @ process returning this

write(10, "36.72.135.58 - - [22/jul/2016:03:15:35 +0700] \"get /test11.php http/1.1\" 500 211 \"-\" \"mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, gecko) chrome/51.0.2704.103 safari/537.36\"\n", 198) = 198 times({tms_utime=29996, tms_stime=4, tms_cutime=0, tms_cstime=0}) = 4967918020 gettimeofday({1469132442, 496002}, null) = 0 gettimeofday({1469132442, 496046}, null) = 0 shutdown(17, shut_wr)                   = 0 poll([{fd=17, events=pollin}], 1, 2000) = 1 ([{fd=17, revents=pollin|pollhup}]) read(17, "", 512)                       = 0 close(17)                               = 0 read(5, 0x7fff82f5cf67, 1)              = -1 eagain (resource temporarily unavailable) gettimeofday({1469132442, 496411}, null) = 0 accept4(4,  <detached ...> 

i had problem , solved increasing first_byte_timeout of varnish @ /etc/varnish/default.vcl default 60 change according needs.


Comments