1

我正在尝试在 Apache 2.0/2.2/2.4 上同时运行数百个 cgi 程序(perl 或其他语言)。我的测试环境是具有 1GB RAM 的 Windows Server 2003 R2。

在程序中,我使用无限循环或“$_ = < STDIN >”来保持每个进程处于活动状态。在 Apache 配置中,我将所有足够大的相关配置,例如 ThreadPerChild 设置为 1000。然后我使用 JMeter 测试了 200 个请求。当我在控制台应用程序中运行 Apache 时,它​​工作正常并且所有 200 个 cgi 进程都在运行。但是,当我将 Apache 作为 Windows 服务运行时,只有 60-100 个进程会同时运行。除非我杀死任何正在运行的进程,否则其他人不会启动。我不知道是什么原因造成的。运行 cgi 程序时 Apache 服务是否存在连接/内存限制?谢谢!

4

1 回答 1

2

MaxClients文件中的参数httpd.conf设置 apache 服务器的最大连接数限制。默认连接限制为 256。

httpd.conf您可以通过打开文件并搜索 MaxClients来检查您的服务器。

linux 中 httpd.conf 的默认位置是/etc/httpd/conf/httpd.conf.

在 windows 上,conf 文件的默认位置是C:/Program Files/Apache Group/Apache/conf/httpd.conf

它看起来像这样。

# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

您可以将MaxClients值设置为所需的任何值,然后重新启动服务器以应用更改。

于 2012-07-10T20:05:22.333 回答