Apache stop takes from 6 seconds to one minute on RHEL 7.6

Latest response

Recently migrated a server from RHEL 6 to 7. It runs 300 vhosts and about 80 virtual IPs. On the RHEL 6 server restarts were quick. On RHEL 7 with apache 2.4 and systemd, the restarts are slow. 'time' run with the systemctl shows the stop part of the action is the culprit. We see anything from 6 seconds to one minute to stop the service. It takes longer to stop if it has not been restarted for awhile (as in a few hours, not days).

We expect to be able to make modifications for new hosts or configurations without impacting the availability of our sites, and this service disruption has become significant enough there is talk of putting that work into maintenance window period.

I put in a support ticket a few days ago complete with sos report, and I can't say they have been quick with suggestions. Google search on this has not revealed a common problem and solution.

Aspects like memory, cores, load are not a factor in the slow stop. It could be that we are in need of some config value, but I don't see anything obvious.

Responses

I'm not quite sure if this is applicable in your case, but worth looking at it https://bugzilla.redhat.com/show_bug.cgi?id=906321

Given the age of that bug report, I think the fix should be in Redhat 7 today. Thanks for the note in any case.

It seems in apache 2.2 and Redhat 6 the previous shutdown method was killproc which is from /etc/rc.d/init.d/functions. When you get through all the if statements in that function, it is essentially the kill command. In the new /usr/lib/systemd/system/httpd.service file it has: ExecStop=/bin/kill -WINCH ${MAINPID} This is supposed to provide a graceful shutdown to apache so that transactions are not lost.

In our case, we are not running an online store or bank, but just a CMS with hundreds of hosts, so the interest is with keeping a service available and showing a page, rather than being offline for a minute at a time with each httpd.conf change.

We changed this to ExecStop=/bin/kill -TERM ${MAINPID} (systemctl daemon-reload must be run after)

Following that change the httpd restart is about 5 to 8 seconds, which is much better for our end users. This was the suggestion from Redhat Tech Support, and given it puts us back to the same behaviour and performance we have had for over a decade, we are confident it is the best solution for us.