• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue Plesk Apache Down 502

Mr_Online

New Pleskian
I have a website with high visitors. My server is down to 502.

My site settings are as follows:




I did a lot of research, but I couldn't find the reason.
 
Are you on a Debian or a Red Hat flavor OS? What's the output of
# journalctl -u httpd
(or # journalctl -u apache2)
 
Are you on a Debian or a Red Hat flavor OS? What's the output of
# journalctl -u httpd
(or # journalctl -u apache2)

OS:
‪CentOS Linux 7.6.1810 (Core)

Product:
Plesk Onyx
Version 17.8.11 Update #52, last updated on April 29, 2019 01:18 AM

journalctl -u httpd output:
Code:
Apr 29 00:34:18 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 00:36:01 host.routergate.com systemd[1]: httpd.service stop-final-sigterm timed out. Killing.
Apr 29 00:36:01 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 00:36:01 host.routergate.com systemd[1]: Unit httpd.service entered failed state.
Apr 29 00:36:01 host.routergate.com systemd[1]: httpd.service failed.
Apr 29 00:36:02 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 00:36:03 host.routergate.com systemd[1]: Started The Apache HTTP Server.
Apr 29 00:36:03 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 00:36:08 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 00:36:09 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 00:36:09 host.routergate.com systemd[1]: Started The Apache HTTP Server.
Apr 29 00:36:10 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 00:36:14 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 00:36:15 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 00:36:15 host.routergate.com systemd[1]: Started The Apache HTTP Server.
Apr 29 00:36:19 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 00:36:23 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 00:36:24 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 00:36:24 host.routergate.com systemd[1]: Started The Apache HTTP Server.
Apr 29 01:19:40 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 01:19:54 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 01:19:58 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 01:19:58 host.routergate.com systemd[1]: Started The Apache HTTP Server.
Apr 29 01:21:49 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 01:22:02 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 01:22:03 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 01:22:04 host.routergate.com systemd[1]: Started The Apache HTTP Server.
Apr 29 01:22:19 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 01:22:23 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 01:22:24 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 01:22:24 host.routergate.com systemd[1]: Started The Apache HTTP Server.
Apr 29 01:23:15 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 01:23:29 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 01:23:30 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 01:23:30 host.routergate.com systemd[1]: Started The Apache HTTP Server.
Apr 29 03:57:06 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 03:57:20 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 03:57:21 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 03:57:21 host.routergate.com systemd[1]: Started The Apache HTTP Server.
Apr 29 04:07:19 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 04:07:33 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 04:07:34 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 04:07:34 host.routergate.com systemd[1]: Started The Apache HTTP Server.
Apr 29 06:27:41 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 06:27:54 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 06:27:56 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 06:27:56 host.routergate.com systemd[1]: Started The Apache HTTP Server.
Apr 29 06:32:57 host.routergate.com systemd[1]: Stopping The Apache HTTP Server...
Apr 29 06:33:01 host.routergate.com systemd[1]: Stopped The Apache HTTP Server.
Apr 29 06:33:02 host.routergate.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 06:33:03 host.routergate.com systemd[1]: Started The Apache HTTP Server.

I restart httpd when I get 502 status code, is working as temporary.
 
Please check the last lines of /var/log/httpd/error_log for more information on the reason why Apache has stopped. You can also simply try to restart it by
# service httpd start
and see what happens there.
 
You seem to be touching limits frequently. Do you have enough RAM for what you are doing?

[Mon Apr 29 00:06:08.496095 2019] [mpm_event:error] [pid 27514:tid 140174937577600] AH00484: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
...
[Mon Apr 29 03:29:02.428330 2019] [mpm_event:error] [pid 2186:tid 140376317364352] AH00484: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
...
[Mon Apr 29 05:58:02.400078 2019] [mpm_event:error] [pid 16532:tid 139773508204672] AH00484: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting

The default setting for MaxRequestWorkers is 256, meaning that Apache will process no more than 256 requests at the same time. However, that is a pretty high number that should normally never be reached. As your server reaches the limit, it is probably either under attack (brute-force attack or similar) or single requests take so much time that while they are still running, a new process must be started to serve the next request.

I suggest these changes:

1) Make sure that you have the Fail2Ban service configured and running, especially on the Apache and Apache Bad Bots jails.

2) Make sure to configure Apache as "MPM Prefork" in Tools & Settings > General Settings > Apache Webserver.

3) Disable all unnecessary Apache modules from the Apache Configuration (for configuration see previous step) configuration to lower the load on the system.

4) If your RAM and CPU power allows it, increase MaxRequestWorkers. Check your file /etc/httpd/conf.d/apache_limit.conf for that. Either add a line "MaxRequestWorkers 384" (or any other number higher than 256) to the section or, if the file is empty, create a section like
<IfModule mpm_prefork_module>
MaxRequestWorkers 384
</IfModule>
My personal opinion is, that there should not be any need to increase this setting. The problem is likely located elsewhere. 256, the default, is a lot. With approximately 1000 domains per host that we operate we never reach such a high number. You might want to think about other entries in the section, e.g. StartServers, MinSpareServers, MaxServers. See the Apache documentation about that.

Here you can find a script that gives recommendations on the "max" settings of Apache in your system:
https://raw.githubusercontent.com/will-parsons/apachebuddy.pl/master/apachebuddy.pl
 
Back
Top