The impact of Apache graceful restarts and user experience

13,508

Solution 1

When performing a graceful restart, existing connections should run to normal completion at which point their workers will terminate. New workers should already be started to handle new connections.

You shouldn't notice any connection failures or slow page loads but in practice you may see new connections queue briefly while the config is re-loaded by the master thread (mine takes under half a second)

If you are restarting to pick up a new config then there is a risk there may be a config error which could prevent the server restarting properly.

If the server is in an abnormal state it may fail to restart gracefully (perhaps thats why you are considering a graceful restart)

Solution 2

If Apache is serving static files, and isn't acting as the front to something like , it's pretty smooth. Most users won't even notice, and those that do will consider it normal glitchiness. Apache won't serve new requests until the old ones are served, so you'll be waiting until they all finish up. If someone is downloading a 500MB file at 68KB/s you may be waiting a LONG TIME, during which no other serving is happening.

If Apache is fronting an application server, the situation can be very different. From experience, the UX for interacting with that server will be very bad until the app server is up, loaded, and the caches are warmed.

Share:
13,508
stellarchariot
Author by

stellarchariot

Updated on September 18, 2022

Comments

  • stellarchariot
    stellarchariot almost 2 years

    Is it safe to perform a graceful restart of Apache on a production server? What effects will a graceful restart cause and what would be the impact (if any)? Will there be any detrimental impacts (e.g. downtime, even if it is for a short time)?

    I have considered the following resources, but it is still unclear what the impacts on users will be:

  • Sreeraj
    Sreeraj over 9 years
    Also, it is VERY important to do a /etc/init.d/httpd configtest before proceeding with any kind of apache restarts on a production server.
  • stellarchariot
    stellarchariot over 9 years
    Indeed — it is quite important to run a configtest. IIRC, I think with later versions of Apache might perform an implicit configtest before a graceful restart, and if it fails the configtest, it won't continue with the restart.
  • covener
    covener over 9 years
    " Apache won't serve new requests until the old ones are served, so you'll be waiting until they all finish up. If someone is downloading a 500MB file at 68KB/s you may be waiting a LONG TIME, during which no other serving is happening." This is not accurate. The configuration is reloaded immediately and new child processes are created, accept connections, and process requests while the previous generation are finishing their last requests.