代码之家  ›  专栏  ›  技术社区  ›  Majid Abdolhosseini

Apache2.4PHP7.2Apache(php模块)将最大连接数增加到10000个

  •  1
  • Majid Abdolhosseini  · 技术社区  · 7 年前

    如何在apache中增加最大连接数以处理10000个并发连接 我正在测试 https://loader.io ,它最多只能处理5000个并发连接(在15秒内)。

    这是我当前的apache配置:

    DefaultRuntimeDir ${APACHE_RUN_DIR}
    Timeout             300
    <IfModule prefork.c>
        StartServers            100
        MinSpareServers         100
        MaxSpareServers         100
        ServerLimit             10000
        MaxClients              10000
        MaxRequestWorkers       10000
        MaxRequestsPerChild     4000
    </IfModule>
    PidFile ${APACHE_PID_FILE}
    KeepAlive On
    MaxKeepAliveRequests 1000
    KeepAliveTimeout 5
    User ${APACHE_RUN_USER}
    Group ${APACHE_RUN_GROUP}
    HostnameLookups Off
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    IncludeOptional mods-enabled/*.load
    IncludeOptional mods-enabled/*.conf
    Include ports.conf
    <Directory />
            Options FollowSymLinks
            AllowOverride None
            Require all denied
    </Directory>
    <Directory /usr/share>
            AllowOverride None
            Require all granted
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>
    
    AccessFileName .htaccess
    <FilesMatch "^\.ht">
            Require all denied
    </FilesMatch>
    
    LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
    LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %O" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent
    
    IncludeOptional conf-enabled/*.conf
    IncludeOptional sites-enabled/*.conf
    ServerName localhost
    

    考虑一下,我的硬件没有问题, 我检查了我的资源使用情况,在我的测试中,我从未通过20%的cpu和内存使用率。

    1 回复  |  直到 7 年前
        1
  •  4
  •   Majid Abdolhosseini    7 年前

    我为Apache找到的最佳调优是这一部分,它已经在我的服务器上完美运行:

    <IfModule prefork.c>
        StartServers            20
        MinSpareServers         20
        MaxSpareServers         50
        ServerLimit             5000
        MaxRequestWorkers       5000
        MaxRequestsPerChild     10000
    </IfModule>
    

    我相信这个配置适合高流量服务器。

    推荐文章