skip to Main Content

I have an idea for an application that I’m working on and I need to know if this will be possible.

I have a script that uses the eBay API to search for items. It will keep requesting info from eBay until an item matching the criteria is returned or it runs for 240 seconds, in which case it sends false back to the client and then restarts itself. The data that gets sent back would be done so through a websocket.

I need about 100 instances of this script running at once, concurrently.

I will launch them all with one PHP for loop, using cURL with curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);.

I am unsure of how PHP gets executed on the server. Will it wait for one instance of the script to finish executing before launching the next one? Or will it launch all 100 instances of this script at once?

2

Answers


  1. It will run them all at once. (As long as they’re not in a shell script and running synchronously, that is.)

    Login or Signup to reply.
  2. It depends .. if you launch them from a shell script, eg:

    ./run.sh
    

    Which contains a single execution of PHP, it will block on execution, and not return until the PHP process is complete.

    However, if you run the same script as:

    ./run.sh &
    

    It will return immediately … you could run many instances of php by firing off in this manner.

    There are countless ways to go about this … the issue you’ll have is getting the data from the prior processes – are they writing to a fail, or db? How do they let you know the item has or has not been found?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search