Apache: restart != graceful

While chatting with a friend last week, he mentioned that he uses the apachectl restart option to get Apache to reread configuration files. This works, but it forcefully terminates all children (even ones processing requests), and can lead to user sessions getting blotched. As of Apache 1.3, you can now use the apachectl graceful option to gracefully restart a web server:

$ apachectl graceful

This utilizes the generation values in the Apache scoreboard, and allows each child to die once they complete the request processing loop. If you are interested in seeing how this is done, check out prefork.c in the Apache source code.

2 thoughts on “Apache: restart != graceful”

  1. I thought everyone knew graceful – obviously not ;)
    In 2.2 there’s a new way of stopping called graceful-stop:

    Signal: WINCH
    apachectl -k graceful-stop

    If we forget about the possible problems with that (see warnings[1]), then this is
    a very nice alternative to graceful for a couple of reasons – you get a full stop, so
    modules are reloaded and even better, you could upgrade to a new version
    immediately by doing something like:

    apachectl -k graceful-stop && apachectl -k start

    [1] http://httpd.apache.org/docs/2.2/stopping.html#gracefulstop

Leave a Reply

Your email address will not be published. Required fields are marked *