Restarting Apache without killing active connections

Changes to Apache web server’s configuration typically warrant a necessary immediate restart of the Apache. This is necessary in order for the new configuration changes to take effect due to the way Apace loads configuration settings at start-up.

Examples of changes which would warrant a restart in order to take immediate effect would be changing (adding or removing) an IP address, modifying the maximum connections limit, installing or uninstalling module files, changing virtual host configurations, and the list goes on, etc.

What is a Graceful Restart, and Why Bother Restarting Apache Gracefully?

Chances are you are already aware that the above situations would require a restart of Apache. The question that needs to be answered is “Why restart with the graceful command rather than the standard restart command.

The answer lies in the receiving end of the HTTP connections; your Apache client connections. When you restart Apache normally, it will kill any established and active connections to all visitors browsing any site hosted through your Apache web server instance.

Scenarios such as the following could be potential points of frustration for the visitors to the sites served up by your Apache web server.

  • A visitor is making a purchase through an commerce site hosted on the server. Apache is restarted in the middle of this data transfer, and the user’s session and all submitted data is lost, forcing them to start over, wondering if their order went through the first time or not, and if they will be double charged.
  • A visitor filled out a lengthy form, and just barely submitted the data. Apache is restarted in the middle of this data transfer, and the user’s session and all submitted data is lost, forcing them to start over.
  • A visitor is downloading a large file over http on a site served by Apache, and the file download is almost completed. Apache is restarted, and their connection fails forcing them to restart the download.

How to Restart Apache Gracefully to Avoid Dropping Client Connections

If Apache web server is configured on your Linux installation as a service and has an entry in the init.d then you may use this command to do a graceful restart of Apache web server and avoid killing any active connections.

service httpd graceful

Compartir:
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Slashdot
  • Technorati
  • Facebook
  • LinkedIn
  • Google Bookmarks
  • Current
  • Netvibes
  • Ping.fm
  • SphereIt
  • Sphinn
  • Tumblr
  • Live
  • Yahoo! Buzz

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply