dongmaomou4117 2012-03-21 15:13
浏览 81

PHP MySql - 如何确定进程的优先级

I have a little more than hundred php scripts running on my server right now. Each one of them run loops and insert data into my db. I did that in order to learn killing processes in mysql. So to kill them, I coded a php file that loops through the processlist and kill them one by one. The problem is that this script is not executed. It keeps loading in my browser (no errors...). Also do note that I can't manually launch a show processlist in mysql, as mysql is totally overloaded at the moment, and nothing is responding. So what I guess is that my 'killing process' script is the last one on the queue and will only be executed at the end. So my question is to know if there is a way to force a process in mysql and put it at priority number one. Thank you in advance for your replies. Cheers. Marc

This is how I am killing the processes:

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

}
  • 写回答

1条回答 默认 最新

  • drdr123456 2012-03-22 19:23
    关注

    I'm not sure if this will actually affect MySQL, but on Unix/Linux, you could try calling proc_nice() near the top of your script with a negative increment (like -20). It basically does the same thing as the nice command.

    From the Wikipedia page on nice:

    "... nice is used to invoke a utility or shell script with a particular priority, thus giving the process more or less CPU time than other processes. A niceness of −20 is the highest priority and 19 or 20 is the lowest priority. The default niceness for processes is inherited from its parent process, usually 0."

    评论

报告相同问题?

悬赏问题

  • ¥30 win c++ socket
  • ¥15 CanMv K210开发板实现功能
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的