Server Reached MaxRequestWorkers Setting

20,320

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.

Share:
20,320

Related videos on Youtube

Ulugbek Khalilov
Author by

Ulugbek Khalilov

Updated on September 18, 2022

Comments

  • Ulugbek Khalilov
    Ulugbek Khalilov over 1 year

    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
    </IfModule>
    

    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?

    • ezra-s
      ezra-s about 7 years
      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.
    • titus
      titus about 7 years
      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.
    • Ulugbek Khalilov
      Ulugbek Khalilov about 7 years
      @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.
    • titus
      titus about 7 years
      @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.
    • Ulugbek Khalilov
      Ulugbek Khalilov about 7 years
      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
      Ulugbek Khalilov about 7 years
      I just checked MySql log and found some Warnings (` could not be resolved: Name or service not known` and could not be resolved: Temporary failure in name resolution)