Both keepalived and zookeeper can be used for high availability, and high availability is typically considered in conjunction with load balancing, so the load balancing capability is often considered
Here's a comparison of keepalived and zookeeper:
First, a summary of the comparison:
1, keepalived:
Advantages: Simple, basically do not need to do anything on the business level, you can achieve high availability, the main recovery disaster. and disaster-tolerant downtime is also relatively short.
Disadvantage: It is also simple, because there is no complicated logic for VRRP, master and standby switching, so it is impossible to deal with some special situations, such as the problem of primary and standby communication link, which can lead to brain fissure. At the same time, keepalived is not easy to do load balancing.
2, Zookeeper:
Pros: can support high availability, load balancing. is a distributed service in itself.
Cons: close to business integration. You need to write the logic in the business code that ZK uses, such as registering a name. Pull the name corresponding to the service address and so on.
So the difference is obvious. In terms of simplicity: keepalived is the simplest and zookeeper slightly more complex.
From the load balance ability, zookeeper strong, keepalived weak a lot.
From the point of view of business: Zookeeper is the closest, and keepalived is not related to the business level.
KeepAlive can only select one machine as the host, so keepalive can only implement M:1 backup
Zookeeper can elect n machine as host, it can realize m:n backup
Second, specific details of the comparison:
1. From the perspective of the main passive
We know that Nginx server is usually combined with keepalived, so how does keepalived know if Nginx is alive? It is nginx to report information to keepalived. No. Keepalived is the initiative to send the request to Nginx, if there is a response, then Nginx is available.
For zookeeper, Hdfs,hbase,yarn is highly available based on zookeeper, where the zookeeper is passive, meaning Hdfs,hbase,yarn actively writes data to zookeeper.2. Considering from the load angle
Keepalived can help us do master-slave, master and slave division is specified by the configuration file (the master-slave priority difference >50), if the master is not hung off, then a large number of requests through the main and then load to the back-end nginx, and from if want to function only wait until the master hangs.
And the use of zookeeper do ha,zookeeper can be said to be "everyone equality", the client regardless of access to follower, or observer, XOR or leader, can give us a corresponding result, can be very good to achieve load balance, This can also be said to be an advantage of zookeeper.
3. From the point of view of storing data
Keepalived can not store data, assuming that the master of Keepalived now has 50 connections, if there is no external database to store the information of these connections, the main hangs, the connection information is lost, so use keepalived need an external database, But if the master hangs up at the same time the database also hangs, then over, the information will be lost, or from up, not even the database, then the connection information will be lost.
Zookeeper can store data, zookeeper can create a znode, which holds data, zookeeper can do a distributed data consistency, zookeeper each node view is consistent, the data itself can achieve final consistency, In other words, one server hangs up, and the other server has data, so there is no need for additional databases, and zookeeper itself can store a certain amount of information. This can also be said to be another advantage of zookeeper.
4. From a business perspective
Keepalived can be said to be relatively simple, just need a simple configuration, you can use the keepalived scene: if we simply need to know the current business in which is the main, which is from, then you can choose Keepalived.
If in addition to high availability, such as kafka,storm and so on to write some data zookeeper, this time need to zookeeper.