《2019年构建强一致性分布式数据库TiDB.pdf》由会员分享,可在线阅读,更多相关《2019年构建强一致性分布式数据库TiDB.pdf(42页珍藏版)》请在三个皮匠报告上搜索。
1、构建强一致性分布式数据库 TiDBR&D Engineer PingCAP目录What is TiDB?How to test?What is TiDB?Single PointSingle Point of FailureAsynchronous ReplicationA=1B=2A=1MasterSlaveAsynchronous ReplicationA=1B=2A=1B=?MasterSlaveSynchronous ReplicationA=1B=2A=1B=2MasterSlaveSynchronous ReplicationA=1B=2A=1B=2MasterSlaveServi
2、ng?Slave-Master?Huge Amounts of DataMasterSlaveMasterSlaveMasterSlaveOpen-source NewSQL database High availability Strong consistency Horizontal scalability Support the MySQL wire protocol https:/ wired protocolSQLNoSQLtidb-servertikv-serverNo single point of failure Automatic failoverHigh Availabil
3、ity at ScaleSnapshot isolation TiDB Linearizability TiKVStrong Consistency at ScaleRaftClientA=1B=2State MachineA=1B=2LogRaft ModuleA=1B=2State MachineA=1B=2LogRaft ModuleA=1B=2State MachineA=1B=2LogRaft ModuleLeader election Voting for leader Network isolation/node failure tiggers election Log repl
4、ication Leader handles client requests,append logs Replicate logs to followers Constraints Quorum:log replication,leader election Up to date:leader electionRaft:Key PointsLazy Peer Cross DC,cross regions deploymentLearner Cross DC,cross regions backupJoint consensus Safe membership changingRaft:New
5、FeaturesRaft:Lazy Peer3-DC in 2 regions deploymentRaft:LearnerFollowerFollowerLeaderLearnerReplace nodes?Node2Node1Node3Node2Node1Node3Node4Node2Node1Node4Raft:Joint consensusNode2Node1Node3Node2Node1Node4How to test?Distributed Multiple Components Strong guarantee on weak foundation 2-4%of disk dri
6、ves fail each year N x 2-4%Broken optic cable Its complicated!Unit tests Integration tests Fuzz testing libFuzzer AFL Fault injection Failpoint,https:/www.freebsd.org/cgi/man.cgi?query=fail Jepsen,https:/ framework for distributed systems verification,with fault injectionFound bu