It is possible to propagate entries of any data type in stick tables across multiple HAProxy instances over TCP connections in a multi-master configuration. Each instance pushes its local updates and insertions to remote peers, with the pushed values overwriting the existing ones without aggregation. Interrupted exchanges are automatically detected, and the system recovers from the last known state.

Additionally, during a soft restart, the old process establishes a TCP connection to the new one to push all its entries before the new process attempts to connect to other peers. This mechanism ensures rapid replication during reloads, typically taking only a fraction of a second, even for large tables.

It is important to note that Server IDs are used to identify servers remotely. Therefore, it is crucial that the configurations are consistent across all instances, or at the very least, that the same IDs are enforced on each server among all participants.

icon
If you intend to use HAProxy services in a Master-Master cluster configuration, ensure that the local server hostnames are set as the peer server names. Otherwise, the peer connections will not function correctly.
icon
If you wish to configure HAProxy services in a Master-Slave cluster, ensure that the local server hostname for the master server is set as the peer server name. Otherwise, the peer connections will not function properly.

With Roxy-WI, you can easily add peers through the graphical interface. To add a peer, go to the HAProxy => Add proxy section and select the Peers tab. You will see the following form:

peers_interface

1. Select a server from the Select server drop-down list for which you would like to create a peer.

2. Enter a peer name in the Peers name field.

3. In the Peers servers field, set the peer definitions, including the name of each peer server, as well as the address and port on which each server will listen.

4. Click Add peer to create the peer. If you need to generate the peers section for the configuration file in accordance with HAProxy syntax requirements, click Generate config. The following window will appear:

generated config

Peers are often use in configurations that use HAProxy in active-active clusters or when sharing stick tables between master-slave servers. In such setups, a new client connection may be directed to one of several HAProxy servers, such as when utilizing Amazon Elastic Load Balancer. While all stick table entries can be stored on a single server, the entries on another server may differ significantly. To solve this issue, you can add a peers section.

Change your stick table definition to include a peers argument:

The exchange of stick table entries between the two servers will occur. However, the servers do not aggregate their individual counters, meaning that the http_req_rate on one server will overwrite the value on the other. As a result, the total sum will not be accessible across both servers.