Networking HowTos
Networking HowTos

Reload HAProxy Config with Minimal Downtime

February 11, 2012 Linux

Restarting HAProxy using the default init scripts will kill any existing connections, and prevent any new connections while it restarts. With the init script restart method (eg ‘/etc/init.d/haproxy restart’), if there are any configuration errors, the service wont start up again. This might be fine for low volume sites, but if you are dealing with heavy traffic, you would want to reload the configuration with the smallest amount of downtime possible.
Thankfully HAProxy provides the ability to do this. The ‘-st’ and ‘-sf’ parameter options are used for hot configuration changes.
Both parameter options allow for hot configuration changes, with the difference being that the ‘-st’ option forces the existing HAProxy instance to kill all existing connections, where as the ‘-sf’ option tells the existing HAProxy instance to finish doing any work, and then softly close.
If there are any configuration errors in the config file, HAProxy will not complete the configuration reload, and will remain running with the existing config.
Example of a configuration reload using -sf (wait for HAProxy to finish any ‘work’):

$ sudo haproxy -p /var/run/ -sf $(cat /var/run/

You Might Also Like

  • Potato October 20, 2012 at 9:08 am

    For RHEL/CentOS/Fedora, the packaged init scripts provide a reload method that implements what you mentioned in this article.