• Websites running slow and Apache shows error: server reached MaxClients setting on Plesk for Linux

Symptoms

Loading the website takes too much time or finishes with "504 Gateway Time-out" error. The following error appears in the /var/log/httpd/error_log:

[error] server reached MaxClients setting, consider raising the MaxClients setting [warn] mod_fcgid: process 2968 graceful kill fail, sending SIGKILL

Cause

The connections limit defined by MaxClients is reached.

Resolution

Connect to the server via SSH.

By default, Apache in Plesk is not configured for high-loaded sites. It is recommended to tune Apache performance as it described here: http://httpd.apache.org/docs/2.2/misc/perf-tuning.html or https://httpd.apache.org/docs/2.4/misc/perf-tuning.html

To resolve the issue with the MaxClients limit, adjust the /etc/httpd/conf/httpd.conf(/etc/apache2/conf/apache2.conf for Debian 7/Ubuntu 12/14) file on SystemV OSes (CentOS 6 or lower), increasing the MaxClients value (e.g., to 100):

<IfModule prefork.c>
StartServers 5
MinSpareServers 10
MaxSpareServers 25
MaxClients 100
MaxRequestsPerChild 10000
</IfModule>

<IfModule worker.c>
StartServers 5
MinSpareThreads 10
MaxSpareThreads 25
ThreadsPerChild 50
MaxClients 100
MaxRequestsPerChild 10000
</IfModule>

Note: For CentOS 7, file /etc/httpd/conf.d/mpm_prefork.conf should be edited instead of [HTML_REMOVED] section. > If the error persists, consider increasing MaxClients limit again until the issue is fixed. For Debian 8 and 9/Ubuntu 16 and 18, use the following files /etc/apache2/mods-available/mpm_prefork.conf and > /etc/apache2/mods-available/mpm_worker.conf

If the error is still shown, check all files where MaxClients directive defined. It can be done with the following command:

grep -iRl "MaxClients" /etc/

If there is no such option at all, add it manually to files listed above. Additional information

The MaxClients directive was the name for MaxRequestWorkers directive before version Apache 2.3.13:

  • MaxClients has been renamed to MaxRequestWorkers, which describes more accurately what it does. For async MPMs, like event, the maximum number of clients is not equivalent than the number of worker threads. The old name is still supported.

This article was last modified: Jan. 9, 2019, 3:46 p.m.

0 Comments

Please log in to leave a comment.

Add or change tags.

A comma-separated list of tags.

Share

Hacker News

Top