General Overview:
keepalived is a software similar to the Layer3, 4 & 5 switch, which is what we normally call the 3rd, 4th, and 5th layers of exchange. The role of keepalived is to detect the state of the Web server, if a Web server freezes, or a work failure occurs, keepalived detects and rejects the failed Web server from the system. When the Web server is working properly, Keepalived automatically joins the Web server to the server farm, all of which are automatically completed without human intervention and need to be done manually to repair the failed Web server
HAProxy provides high availability, load balancing, and proxies based on TCP and HTTP applications, supporting virtual hosting, which is a free, fast, and reliable solution. Haproxy is especially useful for Web sites that are heavily loaded, and often require session-hold or seven-tier processing. The haproxy runs on the current hardware and can support tens of thousands of concurrent connections. and its operating mode makes it easy and safe to integrate into your current architecture, while protecting your Web server from being exposed to the web.
Here I use Haproxy to load multiple Redis servers and then monitor the haproxy with keepalived:
(primary) Server a:10.10.51.231
(from) Server b:10.10.51.232
vip:10.10.51.230
Keepalived Monitor A, B on the haproxy, the use of keepalived VIP drift technology, if a, b Haprox are working properly, VIP and High priority server (master server) binding, when the primary server when the drop, then the slave server bound, The VIP is exposed to the external access of the ip;haproxy using keepalived production of the VIP to the multi-redis (from) Read load, when a redis when off, then remove it, reply to join the cluster.
Keepalived+haproxy for high-availability load balancing