dongxi1879 2014-05-27 14:55
浏览 127

通过PHP exec运行高性能C程序

We are designing a very basic UI for a traffic generator(High performance). It works fine when we run the binary over the shell directly but the performance drops when we do an exec through php script. It slows down terribly.

We have searched and it might be due to the apache environment not creating a thread for the exec.

Is there any way to decrease the processing time or through some other server side scripting?

Thank you.

  • 写回答

1条回答 默认 最新

  • doudui2229 2014-05-27 15:00
    关注

    You can run commands in background using exec. Just append > /dev/null & at end of command. It will execute that command in shell and return immediately without waiting for command to finish.

    exec($cmd . " > /dev/null &");
    

    Solution1

    You can make changes in php.ini for increasing performance.

    Like increase memory_limit to higher value with respect to your RAM

    Solution2

    You are executing the program as webuser(nobody/apache/ww-data) which is a less preivilged user.That is the problem. You can execute that command as more previlged user / root using sudo. Try sudo in php exec()

    评论

报告相同问题?

悬赏问题

  • ¥15 lammps Gpu加速出错
  • ¥15 关于PLUS模型中kapaa值的问题
  • ¥15 关于博途V17进行仿真时无法建立连接问题
  • ¥15 机器学习教材中的例题询问
  • ¥15 求.net core 几款免费的pdf编辑器
  • ¥15 为什么安装HCL 和virtualbox之后没有找到VirtualBoxHost-OnlyNetWork?
  • ¥15 C# P/Invoke的效率问题
  • ¥20 thinkphp适配人大金仓问题
  • ¥20 Oracle替换.dbf文件后无法连接,如何解决?(相关搜索:数据库|死循环)
  • ¥15 数据库数据成问号了,前台查询正常,数据库查询是?号