1

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.

ankit409
  • 93
  • 7

1 Answers1

0

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()

Community
  • 1
  • 1
Harikrishnan
  • 9,688
  • 11
  • 84
  • 127
  • Hi Hari. We are running it in the background but the performance still is far inferior compared to executing it on the shell. any thoughts? – ankit409 May 27 '14 at 15:02