Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

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.

share|improve this answer
    
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
add comment

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?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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