HAProxy has very powerful configuration syntax backed by hundreds of parameters. While this makes it quite versatile, trying to write a configuration file from scratch would be extremely difficult. In our case, the amount of parameters we need to set is actually fairly minimal.
We start by setting the global connection limit to 100 connections. This is the amount of connections HAProxy will manage before simply allowing them to queue in the kernel buffer. Generally we would want to set this to the same value we use with max_connections in postgresql.conf, but it's not required.
Next we set the log to global so all HAProxy instances write to the same log output. HAProxy is an HTTP proxy system at heart, so we must ensure the ...