How it works...

HAProxy has a 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 number of parameters we need to set is actually fairly minimal.

We start by setting the global connection limit to 100 connections. This is the number 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 parameter to global so all HAProxy instances write to the same log output. HAProxy is an HTTP proxy system at heart, so we ...

Get PostgreSQL 12 High Availability Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.