“OB Always Ask” is the latest interactive program launched by OceanBase, which provides detailed answers to a topic about distributed database every week. If you have any questions you are interested in, please leave a comment and we will select one question for detailed answers every week.
Distributed consensus Protocol is by far the most effective way to solve the problem of server unreliability because it allows a group of servers to form a collaborative system that can continue to function when some of them fail. The Paxos protocol is almost synonymous with distributed consistency protocol.
The Paxos protocol has a big design assumption that it requires support for multiple votes, that is, multiple logs in the database can be submitted out of order and processed in parallel. However, Raft protocol has a constraint that multiple votes in a database must be executed in sequence and only the first log can be validated. Raft protocol provides a relatively simple implementation of the distributed consistency protocol, and this simplification has made Paxos a ubiquitous protocol.
But there are some gains and some losses, and Raft making this constraint much easier leads to two problems. The first problem is that concurrency becomes worse. Commits that used to support concurrent commits can now only support the completion of one and then the next, so its performance deteriorates. The second is usability. If you use Paxos, when a machine comes online, you can provide services very quickly because you don’t have to wait for the data validation, whereas if you use Raft, you have to wait for all the logs validation to provide services, so there is an availability risk. This can be risky in some scenarios, especially in remote deployment and poor network environments.
All distributed systems are divided into two camps, one is the Paxos camp, including Google Spanner, OceanBase 1.0 and later versions, Amazon DynamoDB and so on. The other camp is Raft, which includes Tencent’s TDSQL and a series of open source databases, where the mysql-based system is basically implemented through Raft protocol.
Whether you choose the Paxos camp or Raft camp, there are pros and cons to each side, and it’s only by balancing the pros and cons and choosing the protocol that works best for you that you can achieve what your product ultimately wants to achieve.
P.s. Anything you want to know or are interested in about distributed databases, please leave a comment, and we’ll bring you a selection of questions every week. See you next time!