New 8 GB Dedicated Server stopped working during peak time and in Apache error.log, I found following errors:

[mpm_prefork:error] [pid 7565] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
[mpm_prefork:notice] [pid 7565] AH00169: caught SIGTERM, shutting down

The website is running on PHP 7.1.2, Apache/2.4.10 (Debian), FPM/FastCGI installed according to this tutorial

After some research, I modified /etc/apache2/mods-available/mpm_prefork.conf, but still, the server goes down during peak time and keep having the same errors.

The last update of mpm_prefork.conf is:

<IfModule mpm_prefork_module>
    StartServers             20
    MinSpareServers       5
    MaxSpareServers      10
    MaxRequestWorkers     1024
    ServerLimit   1024
    MaxConnectionsPerChild   0

The issue makes me worried is that no matter what values are in mpm_prefork.conf, about 6GB of Ram is always free. I assume that some files overwrite /etc/apache2/mods-available/mpm_prefork.conf and the server ignores this file or if not, then I definitely wrote inappropriate settings.

Could you please give some ideas on how to configure the mpm_prefork.conf file or what files could overwrite this?

  • Switch to mpm_event rightaway, you have no reason to use prefork if you have php-fpm as backend Apache is no longer constrained to use a non-threaded mpm. Also be mindful of the settings you specify, it makes no sense to have 1024 workers and just 10 max spare ones and things like that, which will cause unnecessary overhead. Also make sure the file you think are using are really being used, you can check that with mod_status or mod_info. – ezra-s Apr 17 '17 at 12:09
  • Are you sure that the Apache is the problem? I guess you are serving some PHP + MySql? If so check how php is configured, most probably Apache starts workers but PHP never finished the request and you get into trouble. – titus Apr 17 '17 at 15:03
  • @titus Yes, I am using PHP+ MySQL. I did not get your point (Apache starts workers but PHP never finished the request and you get into trouble.), could you please write in more detail. Thank you in advance. – Ulugbek Khalilov Apr 17 '17 at 15:20
  • @UlugbekKhalilov detailed config of Apache and PHP is needed in order to help. And most welcome are mysql logs also. Apache does not shuts down because it reaches MaxRequestWorkers. Something else might eating up your RAM. – titus Apr 17 '17 at 15:22
  • Could you exactly tell me what config should I provide? I can publish anything in order to solve the issue. And please note that More than 5GB of ram is always free. – Ulugbek Khalilov Apr 17 '17 at 15:32

I was having this problem and turns out that I had slow queries and the php took seconds to finish, accumulating processes. So, check your slow logs before changing apache configs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.