php - Apache 2.4 php 7.2 Apache(php 模块)增加最大连接数以处理 10000
问题描述
我有 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
考虑一下,我的硬件没有问题,我检查了我的资源使用情况,我在测试期间从未超过 20% 的 cpu 和内存使用率。
解决方案
我为已经在我的服务器上完美运行的 Apache 找到的最佳调优是这部分:
<IfModule prefork.c>
StartServers 20
MinSpareServers 20
MaxSpareServers 50
ServerLimit 5000
MaxRequestWorkers 5000
MaxRequestsPerChild 10000
</IfModule>
我相信这个配置对高流量服务器有好处。
推荐阅读
- mysql - MySQL:检索 ID,其中 x 个与之关联的 user_id
- android - 检查学校网站是否发布了新笔记的应用程序
- python - 更改列表列表并在 python 中创建一个新列表
- javascript - Google Places - 如何获取纬度和经度值
- java - 在java中为原子块制作包装器
- javascript - 如何检查数组是否是普通的内置数组?
- java - googleApiClient 无法连接
- java - spring boot 2.x 控制台日志不打印映射的控制器信息
- jupyter - 让我们加密和 JupyterHub
- javascript - 如何在 JS 中制作动画以从数组中选择值?