PHP MySql - how to prioritize a process

There are over one hundred php scripts running on my server now. Each one starts loops and inserts data into my db. I did this to learn about killing processes in mysql. So to kill them I coded a php file that iterates over the list of processes and kills them one by one. The problem is this script is not being executed. It keeps loading in my browser (no error ...). Also note that I cannot manually start the show process list in mysql as mysql is completely overloaded at the moment and nothing is responding. So I think my "kill process" script is the last in the queue and will only be executed at the end. So my question is to know if there is a way to force the process into mysql and put it in priority number one. Thanks in advance for your answers. Greetings. Mark

This is how I kill processes:

$qry = mysql_query("SHOW FULL PROCESSLIST");
while ($row=mysql_fetch_array($qry)) {
  $process_id=$row["Id"];
    $sql="KILL $process_id";
    mysql_query($sql);

}

      

+3


source to share


1 answer


I'm not sure if this will affect MySQL, but on Unix / Linux you can try proc_nice()

at the top of your script with negative increments (e.g. -20). This basically does the same thing as the command nice

.

From the Wikipedianice

page at :



"... nice is used to invoke a utility or shell script with a specific priority, which gives a process more or less CPU time than other processes. Goodness -20 is the highest priority and 19 or 20 is the lowest priority. By default, processes inherit from its parent process, usually 0.

0


source







All Articles