What is the difference between keepalive and heartbeat?

30,015

Solution 1

Believe the question has been very precisely answered by Willy Tarreau, the author of HAProxy, in http://www.formilux.org/archives/haproxy/1003/3259.html.

Citation from the above link

Heartbeat is not the best tool to get a redundant haproxy setup, it was designed to build clusters, which is a lot different from having two redundant stateless network equipments. Network oriented tools such as keepalived or ucarp are the best suited for that task

The difference between those two families is simple

  1. a cluster-oriented product such as heartbeat will ensure that a shared resource will be present at at most one place. This is very important for shared filesystems, disks, etc... It is designed to take a service down on one node and up on another one during a switchover. That way, the shared resource may never be concurrently accessed. This is a very hard task to accomplish and it does it well.
  2. a network-oriented product such as keepalived will ensure that a shared IP address will be present at at least one place. Please note that I'm not talking about a service or resource anymore, it just plays with IP addresses. It will not try to down or up any service, it will just consider a certain number of criteria to decide which node is the most suited to offer the service. But the service must already be up on both nodes. As such, it is very well suited for redundant routers, firewalls and proxies, but not at all for disk arrays nor filesystems.

(Yeah I know it is an old question, but for future reference)

Solution 2

There is no clear, consistent differentiation. Those words are sometimes used more or less interchangeably.

There is a common userland deamon for high availability setups called Keepalived, and the Linux HA project used to have a deamon called Heartbeat, which has now changed to Pacemaker. (I trust you didn't ask for a complete overview of those two systems, and what all the differences are, that would IMHO be off topic.)

In daily use of the terms, I would say the most common use is that:

  • "Keepalive" refers more generally to a system which keeps a service highly available.

  • "Heartbeat" refers more specifically to a communication protocol, where to or more members of a high-availability setup periodically send "Yes, I'm still alive!" messages. Their peers then take action if they don't see a "Yes, I'm alive" message before a set time (i.e. the other host has gone down). This is a bit like feeling for a pulse, hence the name.

Share:
30,015

Related videos on Youtube

aboutstudy
Author by

aboutstudy

PHP程序员一枚,略懂Linux、MySQL、NoSQL、VIM、架构、前端,无证。 http://doophp.sinaapp.com/

Updated on September 18, 2022

Comments

  • aboutstudy
    aboutstudy almost 2 years

    I want to structure a high available server cluster . Now I want to know detail about keepalive and heartbeat, what is the difference between both, and How to choice one.

  • Mike Purcell
    Mike Purcell almost 10 years
    Future reference indeed. Heartbeat was a pain to setup and get working, I found that keepalived was much simpler and with my MySQL Master Master Single Write setup, worked as expected.
  • nelaaro
    nelaaro over 5 years
    See @vange answer. It seems pretty clear to me. Different services different names different design goals and use cases.