[英]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: 在orderWatcher.php中,我做了一些需要很长时间的操作:
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. 我知道我可以运行尽可能多的php脚本作为用户请求它们,但我不确定当我进行exec()调用时是否仍然如此,因为(根据我的理解)这执行shell命令在系统中。
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: 测试不是重点,测试让我质疑以下内容:
PD: Coudln't think of any tags besides php, if you do think of one please tag the question PD:除了php之外没有想到任何标签,如果你想到一个,请标记问题
Calling a command via exec or by a URL doesn't change the amount of scripts that can be run at the same time. 通过exec或URL调用命令不会更改可以同时运行的脚本数量。 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. 服务器可以同时运行的脚本数量取决于它的内存以及许多其他因素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.