Tower of Power

Too sweet to be sour.

*AMP and Runaway Scripts

Peter Zaitsev posted a very interesting test on how PHP and Apache handle runaway PHP scripts.

I’m sure all of us have had a long executing SQL script or at least a runaway script, and he points out even with ignore_user_abort set to FALSE and max execution times set both in PHP and Apache, a runaway SQL query can execute beyond the timeouts, even when aborted by the user (stop button on the browser).

Even using the function connection_aborted() to check for a user abort fails.

However, the script will cease on a user abort if it performs regular ob_flush(); flush(); commands. For example:

1
2
3
4
5
6
7
8
9
<?php
echo("Hello");
for($i=0;$i<10000;$i++)
{
  sleep(1);
  echo('.');
  ob_flush();
  flush();
}

Just one more reason why I love the MySql Performance Blog.

Comments