Re: [PHP] PHP/Apache: script unexpectedly invoked multiple times in parallel every 30 secs.

2009-03-11 Thread Virgilio Quilario
 Hi all,

 I wrote a PHP script running in Apache which takes more than 30 seconds to
 complete. It uses set_time_limit() to extend the time it is allowed to run.
 The script generates thumbnails from a list of images. Upon completion, the
 script redirects the browser to another page using HTTP headers.

 On my local machine (Windows + EasyPHP), the script runs as expected and
 completes after a few minutes.

 I observe an unexpected behavior on my production web server:
 - The script runs as expected for the first 30 seconds.
 - After 30 seconds, the same script with the same parameters starts again in
 a new thread/process. The initial thread/process is *not* interrupted, so 2
 threads/processes run in parallel, executing the same sequence of operations
 with a 30 time shift.
 - The same scenario happens every 30 seconds (i.e.: at 030, 100, 130, and
 so on), multiplying the parallel threads/processes.
 - The browser keeps on loading while the above happens.
 - After some time, the browser displays a blank page and all the
 threads/processes stop. I assume this is due to resources exhaustion, but I
 have no means to check this assumption.

 I deduced the above reading a text file in which I log the sequence of
 called functions.

 Unfortunately I have no access *at all* to my production web server
 configuration (shared hosting, no documentation). I cannot even read the
 configuration settings. While I'm considering moving to another host, I'd be
 extremely pleased to have an explanation of the observed behavior.

 I have browsed the mailing list archives and looked for an explanation in
 other forums to no avail. This thread may deal with the same issue but does
 not include any explanation or solution:
 http://www.networkedmediatank.com/showthread.php?tid=17140

 Thanks for reading, and please do not hesitate to ask for further
 explanations if what I'm trying to achieve was not clear!

 Cheers,
 Marc.


hi Marc,

probably your php file on your production server is index.php.
and you must have generated a image tag with empty src like below:
img src=

with src being empty, browsers will load your index.php as if it was
an image url so loading in parallel.
hope this explains your case.

Virgil
http://www.jampmark.com
Free tips, tutorials, innovative tools and techniques for building and
improving web sites.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP/Apache: script unexpectedly invoked multiple times in parallel every 30 secs.

2009-03-11 Thread Marc Venturini
Thanks for your contribution Virgil. Unfortunately my file is not index.php
(nor anything else declared in a DirectoryIndex directive).

I'm planning to fix the issue using a lock to test that the script is not
already running before starting it again, but I would like to find out the
explanation for this unexpected behavior!

Cheers,
Marc.


On Wed, Mar 11, 2009 at 1:08 PM, Virgilio Quilario 
virgilio.quila...@gmail.com wrote:

  Hi all,
 
  I wrote a PHP script running in Apache which takes more than 30 seconds
 to
  complete. It uses set_time_limit() to extend the time it is allowed to
 run.
  The script generates thumbnails from a list of images. Upon completion,
 the
  script redirects the browser to another page using HTTP headers.
 
  On my local machine (Windows + EasyPHP), the script runs as expected and
  completes after a few minutes.
 
  I observe an unexpected behavior on my production web server:
  - The script runs as expected for the first 30 seconds.
  - After 30 seconds, the same script with the same parameters starts again
 in
  a new thread/process. The initial thread/process is *not* interrupted, so
 2
  threads/processes run in parallel, executing the same sequence of
 operations
  with a 30 time shift.
  - The same scenario happens every 30 seconds (i.e.: at 030, 100, 130,
 and
  so on), multiplying the parallel threads/processes.
  - The browser keeps on loading while the above happens.
  - After some time, the browser displays a blank page and all the
  threads/processes stop. I assume this is due to resources exhaustion, but
 I
  have no means to check this assumption.
 
  I deduced the above reading a text file in which I log the sequence of
  called functions.
 
  Unfortunately I have no access *at all* to my production web server
  configuration (shared hosting, no documentation). I cannot even read the
  configuration settings. While I'm considering moving to another host, I'd
 be
  extremely pleased to have an explanation of the observed behavior.
 
  I have browsed the mailing list archives and looked for an explanation in
  other forums to no avail. This thread may deal with the same issue but
 does
  not include any explanation or solution:
  http://www.networkedmediatank.com/showthread.php?tid=17140
 
  Thanks for reading, and please do not hesitate to ask for further
  explanations if what I'm trying to achieve was not clear!
 
  Cheers,
  Marc.
 

 hi Marc,

 probably your php file on your production server is index.php.
 and you must have generated a image tag with empty src like below:
 img src=

 with src being empty, browsers will load your index.php as if it was
 an image url so loading in parallel.
 hope this explains your case.

 Virgil
 http://www.jampmark.com
 Free tips, tutorials, innovative tools and techniques for building and
 improving web sites.