You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Apache Server 2.4.57(event MPM)最大并发连接/请求数调整及相关配置咨询

Apache Server 2.4.57(event MPM)最大并发连接/请求数调整及相关配置咨询

Hi there! Let’s break down your questions one by one based on your Apache 2.4.57 (event MPM) setup and system configuration:

1. Can we just set MaxRequestWorkers to 16000 to double concurrent capacity?

No, you can’t just change MaxRequestWorkers alone—this value is strictly dependent on two other MPM parameters: ServerLimit and ThreadsPerChild.

For worker/event MPMs, the formula governing maximum concurrent requests is:

MaxRequestWorkers = ServerLimit × ThreadsPerChild

In your current config:

  • ServerLimit 250 (max number of Apache child processes)
  • ThreadsPerChild 32 (threads spawned per child process)
  • 250 × 32 = 8000, which exactly matches your current MaxRequestWorkers

To reach 16000 concurrent requests, you need to adjust either (or both) dependent parameters so their product equals 16000. Two common approaches:

  • Keep ThreadsPerChild 32 and set ServerLimit 500 (500 × 32 = 16000)
  • Or keep ServerLimit 250 and set ThreadsPerChild 64 (250 × 64 = 16000)—just ensure ThreadLimit (currently 64) is at least as high as ThreadsPerChild (which it is here)

If you only set MaxRequestWorkers 16000 without updating ServerLimit/ThreadsPerChild, Apache will either fail to start or silently cap the effective limit at the original 8000. Always run apachectl configtest after changes to catch issues early.

2. How to check the current effective MaxRequestWorkers value?

You have three reliable ways to confirm this:

  • Apache config dump command: Run apachectl -t -D DUMP_RUN_CFG (or httpd -t -D DUMP_RUN_CFG on some systems). Scan the output for the MaxRequestWorkers line—it will show the actual effective value, not just what’s in your config file.
  • Server status page: If you’ve enabled mod_status, visit http://your-server-ip/server-status in a browser. It displays "Max Workers" (your MaxRequestWorkers value) alongside real-time active/idle connection counts.
  • Error logs: If there’s a mismatch between MaxRequestWorkers and the ServerLimit×ThreadsPerChild product, Apache will log an error in its error log (usually /var/log/httpd/error_log or /var/log/apache2/error.log) on startup.

3. Troubleshooting bottlenecks with idle CPU/memory

Since your server’s CPU and memory aren’t maxed out, the bottleneck is likely tied to connection/resource limits rather than raw compute power. Here are quick checks:

  • Use the server-status page to see if you’re consistently hitting the current MaxRequestWorkers limit (look for "Busy Workers" staying close to "Max Workers").
  • Verify if other Apache modules (like mod_proxy if you’re using reverse proxy) have their own concurrency limits restricting throughput.
  • Ensure your system’s network stack isn’t limiting connections (e.g., net.ipv4.tcp_max_syn_backlog or net.core.somaxconn kernel parameters—though these are less likely if CPU/memory are idle).

Your ulimit -a output shows critical system limits that need adjustment for 16000 concurrent requests:

Open File Descriptors

Each Apache connection uses at least a few file descriptors (for the connection itself, log files, static assets, etc.). Your current open files limit is 1024—way too low for 16000 concurrent connections.

Update /etc/security/limits.conf (or create a cleaner override file like /etc/security/limits.d/99-apache.conf) with:

# Soft limit (default for the Apache user)
apache soft nofile 20000
# Hard limit (maximum allowed)
apache hard nofile 40000

(Replace apache with the user your Apache process runs as—common alternatives are www-data or httpd.)

Systemd Overrides (if applicable)

If your server uses systemd to manage Apache, it may override limits.conf settings. Create or edit /etc/systemd/system/httpd.service.d/limits.conf (adjust to apache2.service if needed) with:

[Service]
LimitNOFILE=40000
# Max user processes is already 95053, which is more than enough for 500 Apache child processes—no need to change this unless you scale further
LimitNPROC=95053

Then reload systemd and restart Apache:

systemctl daemon-reload
systemctl restart httpd

Verify the Changes

To confirm limits are applied to the Apache user, run:

su - apache -c 'ulimit -n'

It should return the soft limit you set (20000).


Final Checklist

  1. Update your MPM config to match your target capacity (example for 16000 concurrent requests):
    <IfModule mpm_worker_module>
    ServerLimit              500
    StartServers              10
    MinSpareThreads           75
    MaxSpareThreads          250
    ThreadLimit               64
    ThreadsPerChild           32
    MaxRequestWorkers       16000
    MaxConnectionsPerChild 10000
    </IfModule>
    
  2. Adjust system file descriptor limits as outlined above
  3. Run apachectl configtest to catch configuration errors
  4. Restart Apache
  5. Verify effective MaxRequestWorkers and system limits

备注:内容来源于stack exchange,提问作者rndm_acct1

火山引擎 最新活动