I am trying to find a way to quickly restart Apache to apply configuration changes. The goal is to:

  1. Restart without distributing currently processed requests
  2. Do this as atomically as possible, i.e. the new configuration must be applied on all new requests received from the restart time on, no new requests should by handled by the old version.

Apache has a graceful restart command that satisfies the first goal, the restart command is immediate and existing requests are not affected. However, the restart is not atomic. If there are existing connections to the server in Keep-Alive state, then all the following requests that they send are handled by old processes with the old configuration.

In my case, the Apache server is sitting behind a load balancer which may send hundreds of requests over a single connection. So after the restart, it takes many long minutes until the new configuration is applied to all new requests.

Is there any way to fix this, e.g. make Apache close any existing Keep-Alive connection to an old process after it finishes serving the current request?


Turn KeepAlive Off, do a graceful restart, and keep it off for some time, make the configuration change, and do another graceful restart. This is similar to the practice of reducing the TTL for a DNS entry before a change.

  • After you tell Apache to do a graceful restart, can you tell your NLB to flush its connection table? – Gerald Combs Jul 30 '09 at 21:26
  • If it was a one-time planned upgrade then it'd be a good idea, but unfortunately it wouldn't work in my case because we need to deploy configuration changes frequently and in many times they must take effect immediately. – sagi Jul 31 '09 at 6:44
  • create a dev environment. – ryansstack Dec 23 '11 at 17:59

What about setting your MaxKeepAliveReqests and your KeepAliveTimeout low enough so that clients can still use keepalive, but not keep those connections around as long?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.