Introduction to Percona XtraDB Cluster and HAProxy in 2014 OSDC talk.
Blog: http://blog.wu-boy.com/2014/04/osdc-2014-talk-introduction-to-percona-xtradb-cluster-and-haproxy/
OSDC: http://osdc.tw/program/2014-day2-10.html#content
2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy
1. Introduction toIntroduction to
Percona XtraDB ClusterPercona XtraDB Cluster
and HAProxyand HAProxy
2014.04.122014.04.12
Bo-Yi WuBo-Yi Wu
appleboyappleboy
2. 22
About meAbout me
Github: @appleboyGithub: @appleboy
Twitter: @appleboyTwitter: @appleboy
Blog: http://blog.wu-boy.comBlog: http://blog.wu-boy.com
3. 33
AgendaAgenda
About Percona XtraDB ClusterAbout Percona XtraDB Cluster
Install the first node of the clusterInstall the first node of the cluster
Install subsequent nodes to the clusterInstall subsequent nodes to the cluster
Install HAProxy on the application serverInstall HAProxy on the application server
Testing with a real-world applicationTesting with a real-world application
35. 3535
State TransferState Transfer
Full data SSTFull data SST
– New nodeNew node
– Node long time disconnectedNode long time disconnected
Incremental ISTIncremental IST
– Node disconnected short timeNode disconnected short time
36. 3636
Snapshot State TransferSnapshot State Transfer
MysqldumpMysqldump
– Small databasesSmall databases
RsyncRsync
– Donor disconnected for copy timeDonor disconnected for copy time
– fasterfaster
XtraBackupXtraBackup
– Donor disconnected for short timeDonor disconnected for short time
– slowerslower
37. 3737
Incremental State TransferIncremental State Transfer
Node was in clusterNode was in cluster
– Disconnected for maintenanceDisconnected for maintenance
– Node CrashedNode Crashed
46. 4646
Cluster integrityCluster integrity
wsrep_cluster_sizewsrep_cluster_size
– Configuration versionConfiguration version
wsrep_conf_idwsrep_conf_id
– Number of active nodesNumber of active nodes
wsrep_cluster_statuswsrep_cluster_status
– Should be “Primary”Should be “Primary”
47. 4747
Node StatusNode Status
wsrep_readywsrep_ready
– Should be “On”Should be “On”
wsrep_local_state_commentwsrep_local_state_comment
– Status messageStatus message
wsep_local_send_q_avgwsep_local_send_q_avg
– Possible network bottleneckPossible network bottleneck
wsrep_flow_control_pausedwsrep_flow_control_paused
– Replication lagReplication lag
53. 5353
Cluster replicationCluster replication
Before source return commitsBefore source return commits
– Certify trx on all other nodesCertify trx on all other nodes
Nodes reject on locking conflictsNodes reject on locking conflicts
Commit successfully if no conflicts onCommit successfully if no conflicts on
any nodeany node
54. 54
Node 1
Tx Source
Node 2
Accepted
Node 3
Certify Fails
Client 2
Client 1
Update t set col = '12' where id = '1'
Update t set col = '12'
where id = '1'
Update t set col = '12' where id = '1'
56. 56
Write to all nodesWrite to all nodes
Increase of deadlock errorsIncrease of deadlock errors
57. 57
How to avoid deadlockHow to avoid deadlock
on all nodes?on all nodes?
58. 5858
How to avoid deadlockHow to avoid deadlock
Writing to only one nodeWriting to only one node
– All pessimistic locking happens on one nodeAll pessimistic locking happens on one node
Different nodes can handle writes forDifferent nodes can handle writes for
different datasetsdifferent datasets
– Different database, tables, rows etc.Different database, tables, rows etc.