In distributedAlgorithmA very important algorithm in the field is paxos. How important is it, as mentioned in Google's chubby [1 ].
All working protocols for asynchronous consensus we have so far encountered have paxos at their core.
More details about paxos algorithms are provided in Wikipedia. The Chinese version introduces the choose value rule [2]. The English version introduces the paxos 3 phase commit process [3]. the Chinese version is not written independently from the English version, so it is very complementary. The paxos algorithm was proposed by Leslie Lamport. He wrote in paxos made simple [4]
The paxos algorithm, when presented in plain English, is very simple.
When you have been studying the paxos Algorithm for a long time, it may be a bit frustrating to see the above sentence. However, it is recognized that its algorithms are still cumbersome, especially when usedProgramYour head is full of question marks when you think carefully about all the details. Leslie Lamport also spent nine years improving the algorithm theory.
In fact, for general developers, we do not need to understand all the details of paxos and how to implement it. We only need to know That paxos is a distributed election algorithm. This article mainly introduces common paxos application scenarios. Maybe one day when your system grows to a certain scale, you know that there is such a technology, it helps you solve technical architecture problems correctly and elegantly.
1. database replication, log replication, etc. For example, data replication in bdb uses paxos-compatible algorithms. Paxos is used to maintain data consistency among multiple nodes.
2. Naming Service. For example, a large system usually has multiple interface services that call each other.
1) the general implementation is to write the service IP/hostname into the configuration. When the service fails, you can manually change the configuration file or modify the DNS pointing method to solve the problem. The disadvantage is poor maintainability. The more internal units, the higher the failure rate.
2) LVS dual-host redundancy. The disadvantage is that all units require double resource investment.
By using the paxos algorithm to manage all naming services, high available can be ensured to allocate available services to the client. Zookeeper also provides the watch function, that is, the notification is automatically sent when the watch object changes, so that all clients can use consistent and highly available interfaces.
3. config Configuration Management
1) You can modify the configuration file manually. This method is prone to errors and requires manual intervention to take effect. Therefore, the node status cannot be consistent at the same time.
2) large-scale applications implement their own configuration services. For example, HTTP Web services are used for configuration centralization. Its disadvantage is that after the update, all clients cannot know immediately, and the loading order of each node cannot be guaranteed, resulting in different configurations in the system.
4. membership User Role/Access Control List. For example, in permission settings, once a user sets a permission, for example, from administrator to normal identity, all remote cdns on all servers should take effect immediately, otherwise, it will lead to unacceptable consequences.
5. Number allocation. Generally, the simple solution is to use the database auto-increment ID, which leads to difficulties in database splitting or the guid generated by the program, which usually leads to an excessively long ID. The more elegant way is to use the paxos algorithm to select one of multiple replicas as the master and assign numbers through the master. When the master node fails, use paxos to select another master node.
Some common paxos application scenarios are listed here. For such cases, if other solutions are used, on the one hand, automatic high availability solutions cannot be provided, at the same time, paxos is far from simple and elegant.
Yahoo! The open-source zookeeper [5] is an open-source paxos implementation. Its programming interface looks like a distributed small file system that provides strong consistency assurance. Applicable to all of the above scenarios. However, it is a pity that zookeeper does not follow the paxos protocol, but a 2 phase commit protocol based on its own design and optimization. Therefore, its theory [6] has not been fully proved. However, because zookeeper is in Yahoo! Internal applications have been successfully applied in hbase, Yahoo! Message Broker, fetch service of Yahoo! Crawler and other systems, so you can use it with confidence.
In addition, select an implementation section in paxos made live [7] as the end.
* There are significant gaps between the description of the paxos algorithm and the needs of a real-world system. in order to build a real-world system, an expert needs to use numerous ideas scattered in the literature and make several relatively small Protocol extensions. the cumulative effort will be substantial and the final system will be based on an unproven protocol.
* Because chubby fills in some details not mentioned in the paxos paper, the final implementation system is not a theoretically completely verified system.
* The Fault-Tolerance computing community has not developed the tools to make it easy to implement their algorithms.
* The Distributed Fault-tolerant Algorithm field lacks supporting tools to help implement algorithms. For example, despite the complexity of the compilation field, YACC, anlr, and other tools have minimized the difficulty of this field.
* The Fault-Tolerance computing community has not paid enough attention to testing, a key ingredient for building Fault-Tolerant Systems.
* The Distributed Fault-tolerant Algorithm field lacks testing methods.
Here we need to add a background to prove that the correctness of the Distributed Fault-tolerant Algorithm is usually more difficult than implementing the algorithm. Google cannot prove that chubby is reliable, Yahoo! And cannot guarantee the correctness of its zookeeper theory. Most systems are represented with caution after running for a long period of time in practice. Currently, the system has not found any major problems.
Resources
[1] The chubby lock service for loosely-coupled distributed systems (PDF)
[2] http://zh.wikipedia.org/wiki/paxosalgorithm
[3] http://en.wikipedia.org/wiki/Paxos_algorithm
[4] paxos made simple (PDF)
[5] zookeeper
[6] the life and times of a zookeeper
[7] paxos made live-an engineering perspective (PDF)
From http://timyang.net/distributed/paxos-scenarios/