Changes between Version 4 and Version 5 of PHP


Ignore:
Timestamp:
Nov 13, 2012, 8:48:54 AM (7 years ago)
Author:
burek
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PHP

    v4 v5  
    1313What you want to do is to separate the command-line tool's long processing from your web script execution, to make your script more responsive. So, you have at least 2 options:
    14141. Run the command-line tool (using [http://php.net/manual/en/function.shell-exec.php shell_exec()] for example) in the background and continue with the web script execution, periodically refreshing the status page, showing the current progress
     15 [[Image(ffmpeg_php_1.png)]]
    15162. Create a new "job" (usually a new row in a table of your database) and have some background "worker" process (cron job, shell script, batch script) that will monitor that "job list" to see if there are any new jobs that need processing
     17 [[Image(ffmpeg_php_2.png)]]
    1618
    1719These two methods might seem like the same thing, but they are not. The most important difference is that the 2nd approach scales better with higher web site traffic, because it allows the "worker" process to be running on the completely separate machine. Also, there can be several "worker" machines, working together, splitting the workload, with a trivial synchronization involved.