dongtong2021 2019-05-20 19:44 采纳率: 0%
浏览 183

PHP可以同时处理多少后台进程?

I have a server with the following specifications:

  • 1 vCPU
  • 1 GB RAM
  • 25 GB SSD

Configured with Linux Ubuntu 18.04, apache 2 and php 7.2.

Let's assume that for each visitor entering my page, I run a command in background mode, where it counts from 0 to 100,000 - 1 million:

index.php

exec("php ./countToOneMilion.php > /dev/null &");//This code runs a php file in background mode (if the user closes a browser window, a count still continues)

countToOneMilion.php

$number = mt_rand(100000, 1000000);//Generate a random number
for ($i = 0; $i <= $number; $i++) {
    echo $i;
}

According to phpinfo(), the memory_limity parameter of my server, is set to 127M (which is the default value when installing php and apache).

Now, let's assume that 20 visitors entered in my page. In that case, how will PHP execute the processes in background mode (since counting from 0 to 1 million is often a time-consuming task)?

Will it run 20 times simultaneously (dividing the 127M by 20, thats the number of processes) or will some processes stay on a waiting list until the other processes are over? Or is PHP only able to execute one process at a time (causing the last task from the last user to wait a considerable amount of time to get the count from 0 to 1 million?)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀
    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?