Speeding up a PHP App

r3delmasry

New Member
I have a list of data that needs to be processed. The way it works right now is this:
  • A user clicks a process button.
  • The PHP code takes the first item that needs to be processed, takes 15-25 secs to process it, moves on to the next item, and so on.
This takes way too long. What I'd like instead is that:
  • The user clicks the process button.
  • A PHP script takes the first item and starts to process it.
  • Simultaneously another instance of the script takes the next item and processes it.
  • And so on, so around 5-6 of the items are being process simultaneously and we get 6 items processed in 15-25 secs instead of just one.
Is something like this possible?I was thinking that I use CRON to launch an instance of the script every second. All items that need to be processed will be flagged as such in the MySQL database, so whenever an instance is launched through CRON, it will simply take the next item flagged to be processed and remove the flag.Thoughts?Edit: To clarify something, each 'item' is stored in a mysql database table as seperate rows. Whenever processing starts on an item, it is flagged as being processed in the db, hence each new instance will simply grab the next row which is not being processed and process it. Hence I don't have to supply the items as command line arguments.
 
Back
Top