PhxSQL: A High-Availability & Strong-Consistency MySQL Cluster
Ming CHEN@WeChat
PhxSQL: A High-Availability & Strong-Consistency MySQL Cluster - - PowerPoint PPT Presentation
PhxSQL: A High-Availability & Strong-Consistency MySQL Cluster Ming CHEN@WeChat Why PhxSQL Highly expected features for MySql cluster Availability and consistency in MySQL cluster SVR A Master-slaves replication MySQL (master)
Ming CHEN@WeChat
Highly expected features for MySql cluster
3
Binlog … 3: z 2: y 1: x Innodb
SVR C
MySQL (slave)
Binlog … 3: z 2: y 1: x Innodb
SVR B
MySQL (slave)
Binlog … 3: z 2: y 1: x Innodb
SVR A
MySQL (master)
pull pull client
4
5
High-availability & strong-consisteny MySQL cluster
7
8
modify after_flush add before_recoverty
9
10
concurrently accessing it
11
in an atomic fashion while still serving read/write requests
MySQL cluster powered by Paxos
13
SVR A
Client R Client S Client T
int X=0; int Y=0; void Foo(int a, int b); bool Bar(int a, int b);
invoke: R1, T1, S1, R2, … Paxos
SVR B
int X=0; int Y=0; void Foo(int a, int b); bool Bar(int a, int b);
Paxos
SVR C
int X=0; int Y=0; void Foo(int a, int b); bool Bar(int a, int b);
Paxos
Foo(1, 2); Bar(3, 30) Bar(1, 10) Foo(3, 4)
1: R1: Foo(1, 2) 2: T1: Foo(3, 4) 3: S1: Bar(1, 10) 4: R2: Bar(3, 30) …
invoke: R1, T1, S1, R2, … invoke: R1, T1, S1, R2, …
God
14
SAME binlog
15
client
Binlog … 3: z 2: y 1: x Innodb
SVR B
MySQL (slave)
Binlog … 3: z 2: y 1: x Innodb
SVR A
MySQL (master)
Binlog … 3: z 2: y 1: x Innodb
SVR C
MySQL (slave)
pull pull
16
client
Binlog … 3: z 2: y 1: x Innodb
Phx Plugin Phx Binlog … 3: z 2: y 1: x Paxos Phx Proxy
SVR B
Phx BinlogSvr MySql (slave)
Binlog … 3: z 2: y 1: x Innodb
Phx Plugin Phx Binlog … 3: z 2: y 1: x Paxos Phx Proxy
SVR A
Phx BinlogSvr MySql (master)
Binlog … 3: z 2: y 1: x Innodb
Phx Plugin Phx Binlog … 3: z 2: y 1: x Paxos Phx Proxy
SVR C
Phx BinlogSvr MySql (slave)
pull pull forward
and periodic heartbeat
who forwards requests to current master
PhxBinlog maintained by Paxos
PhxBinlog
17
PhxBinlogSvr A
PhxPlugin:Client R PhxPlugin:Client S PhxPlugin:Client T
master_ver master_id binlog_queue
C1: bool change_master(ver, new_master); C2: int app_binlog(binlog_id, binlog);
Paxos
PhxBinlogSvr B
Paxos
PhxBinlogSvr C
Paxos
C1(1, R); C2(“R_xxx”, “insert foo=2 into table_1”) C1(1, S) C1(1, T)
1: R1: C1(1, R) 2: T1: C1(1, T) 3: S1: C1(1, S) 4: R2: C2(…) …
SM SM
God
SM master_ver master_id binlog_queue
C1: bool change_master(ver, new_master); C2: int app_binlog(binlog_id,binlog);
master_ver master_id binlog_queue
C1: bool change_master(ver, new_master); C2: int app_binlog(binlog_id,binlog);
Easy to integrate into existing system
19
in existing system
PhxSQL cluster and update information in the naming service accordingly
is stale or MySQL clients connects to a slave
naming service master ip: 10.1.1.1 master 10.1.1.1 slave 10.1.1.3 slave 10.1.1.2
PhxSQL
client
daemon
20
1. Read the IP of master from configuration file 2. Get MySQL handler by calling mysql_real_connect(MYSQL *mysql, const char * IP, …) with the IP 3. Invoke other MySQL client API with the handler
1. Read the IP list of PhxSQL cluster servers from configuration file 2. Get MySQL handler by calling PhxSQLClientBase::Connect() with the IP list and then PhxSQLClientBase::GetMySQLFD() 3. Invoke other MySQL client API with the handler
On par with MySQL semi-sync replication
22
Raid10, 1000M NIC
size=1000000 --num-threads=500 --max-requests=100000 --report-interval=1 -- max-time=200
23
5076 46334 25657 4055 47528 20391 insert.lua (100% write) select.lua (0% write) OLTP.lua (20% write)
200 co concu curre rent cl clien ent t thread ads
PhxSQL MySQL 8260 105928 46543 7072 121535 33229 insert.lua (100% write) select.lua (0% write) OLTP.lua (20% write)
500 co concu curre rent cl clien ent t thread ads
PhxSQL MySQL
24
39.34 4.21 140.16 49.27 4.1 176.39 insert.lua (100% write) select.lua (0% write) OLTP.lua (20% write)
200 concurrent client threads
PhxSQL MySQL 60.41 4.58 192.93 70.6 4.17 270.38 insert.lua (100% write) select.lua (0% write) OLTP.lua (20% write)
500 00 concurrent client threads
PhxSQL MySQL
25