使用php运行控制台应用程序的多个实例

时间:2022-01-02 10:55:23

I'm running an apache server on a windows 7 machine.

我在Windows 7机器上运行apache服务器。

I made two script:

我做了两个剧本:

  1. Holds an html file that calls the second multiple times via ajax and outputs the result.
  2. 保存一个html文件,通过ajax多次调用第二个并输出结果。

  3. When called loads a console application which performs a simple task and write the result back.
  4. 调用时会加载一个执行简单任务并将结果写回的控制台应用程序。

The application is executed with php exec() (tested with proc_open() too) and everything seems to work fine even with several ("simultaneously" ajax calls)

该应用程序使用php exec()执行(也使用proc_open()进行测试)即使有几个(“同时”ajax调用),一切似乎都能正常工作

mpm is enabled - mpm-winnt is used.

mpm已启用 - 使用mpm-winnt。

I noticed that if I fire several ajax calls - lets assume 20 calls - the apache server only opens simultaneously 6 processes at max (of the exe file). Even when I watch the processes tab in the task manager I can only see 6 instances of the application being executed in parallel. I expect ~20 - it seems the other calls are waiting for the pool of 6...

我注意到如果我发出几个ajax调用 - 假设有20个调用 - apache服务器只能同时打开最多6个进程(exe文件)。即使我在任务管理器中查看进程选项卡,我也只能看到并行执行的应用程序的6个实例。我期待~20 - 似乎其他电话正在等待6 ...

Any Idea why? and how can I force the server to increase this "pool"?

任何想法为什么?以及如何强制服务器增加此“池”?

EDIT - more information

编辑 - 更多信息

Apache 2.4 (x64)

Apache 2.4(x64)

PHP 5.6 (x64) - used as an apache module.

PHP 5.6(x64) - 用作apache模块。

httpd.conf

httpd-mpm.conf

If i open the program manually it loads as many times as I want.

如果我手动打开程序,它会按我的意愿加载多次。

If I don't use ajax and I open 20 tabs that loads the application - same 6 pool.

如果我不使用ajax并打开20个加载应用程序的选项卡 - 相同的6个池。

The program uses ~70mb (peak) of memory for each instance.

该程序为每个实例使用~70mb(峰值)内存。

2 个解决方案

#1


2  

This limitation isn't server side, but maintained by the web browsers.
RFC suggest that this limitation must be set 2 per servers, but web browsers aren't conform :)
I've found this information from BrowserScope - Max Connections Per Hostname

此限制不是服务器端,而是由Web浏览器维护。 RFC建议每个服务器必须设置2个限制,但Web浏览器不符合:)我从BrowserScope中找到了这些信息 - 每个主机名的最大连接数

Browser | Version | Connections per Hostname | Max Connections
--------+---------+--------------------------+----------------
Chrome  | 32→     | 6                        | 10
Firefox | 26→     | 6                        | 17
IE      | 9→      | 6                        | 35
IE      | 10→     | 8                        | 17
IE      | 11→     | 13                       | 17   
Safari  | 7.0.1→  | 6                        | 17   

#2


0  

It doesn't matter how do you connect to server (via AJAX or by opening multiple tabs). It's anyway affected by limitations that Halayem mentioned above.

如何连接到服务器(通过AJAX或打开多个选项卡)并不重要。无论如何,它受到Halayem上面提到的限制的影响。

For example, if you would try to call php script via another net tool like cURL I'm sure you will see as many program instances as requests were were sent.

例如,如果您尝试通过另一个网络工具(如cURL)调用php脚本,我确信您将看到与发送请求一样多的程序实例。

#1


2  

This limitation isn't server side, but maintained by the web browsers.
RFC suggest that this limitation must be set 2 per servers, but web browsers aren't conform :)
I've found this information from BrowserScope - Max Connections Per Hostname

此限制不是服务器端,而是由Web浏览器维护。 RFC建议每个服务器必须设置2个限制,但Web浏览器不符合:)我从BrowserScope中找到了这些信息 - 每个主机名的最大连接数

Browser | Version | Connections per Hostname | Max Connections
--------+---------+--------------------------+----------------
Chrome  | 32→     | 6                        | 10
Firefox | 26→     | 6                        | 17
IE      | 9→      | 6                        | 35
IE      | 10→     | 8                        | 17
IE      | 11→     | 13                       | 17   
Safari  | 7.0.1→  | 6                        | 17   

#2


0  

It doesn't matter how do you connect to server (via AJAX or by opening multiple tabs). It's anyway affected by limitations that Halayem mentioned above.

如何连接到服务器(通过AJAX或打开多个选项卡)并不重要。无论如何,它受到Halayem上面提到的限制的影响。

For example, if you would try to call php script via another net tool like cURL I'm sure you will see as many program instances as requests were were sent.

例如,如果您尝试通过另一个网络工具(如cURL)调用php脚本,我确信您将看到与发送请求一样多的程序实例。