mhn*_*dev 4 php apache high-traffic
我有 apache(2.4) 和 php(7.2) 项目,其中 apache 使用 mpm_fork 如何增加 apache 中的最大连接数以处理 10,000 个并发连接?我正在使用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
Run Code Online (Sandbox Code Playgroud)
考虑一下,我的硬件没有问题,我检查了我的资源使用情况,在测试过程中我从未超过 20% 的 cpu 和内存使用率。
我发现 Apache 的最佳调整已经在我的服务器上完美运行,这部分是:
<IfModule prefork.c>
StartServers 20
MinSpareServers 20
MaxSpareServers 50
ServerLimit 5000
MaxRequestWorkers 5000
MaxRequestsPerChild 10000
</IfModule>
Run Code Online (Sandbox Code Playgroud)
我相信这个配置适合高流量服务器。
| 归档时间: |
|
| 查看次数: |
6906 次 |
| 最近记录: |