Building high-availability services using Keepalived
High-availability services are those that can survive the failure of an individual machine or network connection. The primary technique for high availability is redundancy, otherwise known as throwing hardware at the problem. Although the eventual failure of an individual server is certain, the simultaneous failure of two servers is unlikely enough that this provides a good level of redundancy for most applications.
One of the simplest ways to build a redundant pair of servers is to have them share an IP address using Keepalived. Keepalived is a daemon that runs on both machines and exchanges regular messages between the two. One of those servers is the primary one and normally has the virtual IP address (VIP). If the secondary server fails to detect the primary server, it can take over the VIP, ensuring continuity of service. In real-world scenarios, you may want more machines involved in the VIP, but for this example, two machines works...