简体   繁体   中英

How many php scripts can my server run simultaneously?

I've a script accesible by the end user that makes the following call:

exec("php orderWatcher.php $insertedId > /dev/null &");

In orderWatcher.php I do some operations that take a long time:

 if (checkSomeStuff) {
     sleep(60);
 }
 makeOtherStuff();

I'm aware that I can have as many php scripts running as users requesting them, but I'm not sure if that remains true when I make an exec() call, since (according to my understanding) this executes a shell like command in the system.

Further more, if I perform the tests (This tests have been modified to keep them relevant to question, they have actually a lot more meaning than this):

class OrderPlacerResultOrders extends UnitTestCase {

    function testSimple() {
        exec("php orderWatcher.php $insertedId > /dev/null &");
        // Wait for exec to finish
        sleep(65);
        $this->assertTrue(orderWatcherWorked(1));
        // No problem here

     }

     function testComplex() {
        for($i = 0; $i < 100; ++$i) {
             exec("php orderWatcher.php $insertedId > /dev/null &");
        }
        // Wait a really long time
        sleep(1000);
        for($i = 0; $i < 100; ++$i) {
        $this->assertTrue(orderWatcherWorked(i));
        // Failure arround the 17th case
        }


     }

}

The tests aren't the main point, the test made me question the following:

  1. How many exec calls to a php script can be made and handled by the server?
  2. If there's a limited amount, it makes a diference that the exec is being requested by two instances of the script (As two different web users calling the script that makes the exec call)? Or is it the same as being called in the same script (As in the tests)?

PD: Coudln't think of any tags besides php, if you do think of one please tag the question

Calling a command via exec or by a URL doesn't change the amount of scripts that can be run at the same time. The amount of scripts that a server can run at the same time depend on it's memory alongside with a number of other factors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM