Bobcares

Active Passive Failover HAProxy: Explained

by | Feb 28, 2023

Let us take a closer look at active passive failover haproxy With the support of our server management support services at Bobcares we will give you a complete note on it.

Active Passive Failover Haproxy

Active-Passive Failover: The use of redundant systems in a failover arrangement to ensure high availability for key applications or services.

Active-passive failover is a strategy that we can use in the context of HAProxy. It is a prominent open-source load balancer and proxy server, to ensure that if one HAProxy instance fails, another instance may take over its job and continue to serve traffic.

Two or more HAProxy instances are running in parallel in an active-passive failover setup. The active node is in charge of processing all incoming traffic and forwarding it to the necessary backend servers. The other instances, referred to as passive nodes, are not actively processing traffic but are ready to take over if the active node fails.

Setup Active Passive Failover Haproxy

To establish active-passive failover in HAProxy, we must configure the active and passive nodes to communicate and monitor each other’s status. This is often accomplished through the use of a combination of health checks, heartbeat messages, and failover scripts.

When the active node fails, the passive node(s) notice it and one of them is promoted to become the new active node. This is referred to as failover, and it often entails adjusting network settings and updating DNS records to guarantee that all traffic is now sent to the new active node.

It is critical in an active-passive failover arrangement to keep the passive nodes in sync with the active node to minimize data loss or inconsistencies when a failover occurs. This can be accomplished through the use of shared storage or by duplicating data between nodes using a tool like rsync or DRBD.

Overall, active-passive failover is a useful technique for ensuring high availability and avoiding downtime in critical systems. However, it’s important to note that failover can still result in some disruption to the service, especially if the failover process takes a long time or if there are issues with the passive node(s) becoming fully operational.

Diagram

Let’s utilize a single HAProxy with two servers, s1 and s2.

When the system boots, s1 is the master and s2 is the backup:

  1. ————-
  2. |  HAProxy  |
  3. ————-
  4. |         `
  5. |active    ` backup
  6. |           `
  7. ——       ——
  8. | s1 |       | s2 |
  9. ——       ——

Configuration: Automatic failover and failback

The setup below instructs HAProxy to utilize s1 when it is available and to fail over to s2 if it is not:

  1. defaults
  2. mode http
  3. option http-server-close
  4. timeout client 20s
  5. timeout server 20s
  6. timeout connect 4s
  7. frontend ft_app
  8. bind 10.0.0.100:80 name app
  9. default_backend bk_app
  10. backend bk_app
  11. server s1 10.0.0.1:80 check
  12. server s2 10.0.0.2:80 check backup

The most crucial term in the above sentence is “backup” on the s2 configuration line.

However, as soon as s1, done restoring, all traffic will fail back to it. This is fine for online apps but not for active/passive systems.

Automatic failover without failback

The setup below instructs HAProxy to utilize s1 when it is available and to fail over to s2 if it is not.

Dues to the stick table, no it wont execute failback automatically once a failover happens:

active passive failover haproxy

In this case, the stick table will retain persistence based on the target IP address (10.0.0.100):

  1. show table bk_app
  2. # table: bk_app, type: ip, size:20480, used:1
  3. 0x869154: key=10.0.0.100 use=0 exp=0 server_id=1

With this configuration, we may force a fail back by deactivating s2 for a few seconds.

[Need assistance with similar queries? We are here to help]

Conclusion

To sum up we have now seen more about the active-passive failover haproxy. With the support of our server management support services at Bobcares we have gone through all of the steps in the process.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF