【问题标题】:Is there a connection/memory limits for Apache Service while running cgi programs?运行 cgi 程序时 Apache 服务是否存在连接/内存限制?
【发布时间】:2012-07-10 02:34:51
【问题描述】:

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

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

【问题讨论】:

    标签: windows perl apache process windows-services


    【解决方案1】:

    httpd.conf 文件中的MaxClients 参数设置 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 值设置为所需的任何值,然后重新启动服务器以应用更改。

    【讨论】:

    • 我尝试了所有配置,但不幸的是它们都不重要。如果只是 conf 问题,它应该适用于控制台应用程序和服务。昨天终于找到原因了。重要的是 Windows 桌面堆大小。 Windows 只为每个用户服务分配 768kb 堆大小,不知何故,我的进程使它 100% 使用并导致其他人失败。还是谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-07
    • 1970-01-01
    相关资源
    最近更新 更多