INTRODUCTION TO GALERA CLUSTER
-GARIMA MASAND
SHORTCOMINGS OF MYSQL REPLICATION
Asynchronous: may result in data loss
Single Threaded: slave lag, performance
penalty
Master-Slave: read-write segregation on
application level
Master-Master: inconsistent data in case of
failures/no automated failover
High Availability: manual intervention
required for traffic shifting
HOW CAN WE OVERCOME THEM?
GALERA CLUSTER CAN HELP US
WHAT IS GALERA?
Galera
DB1 DB3DB2
Galera is a brainchild of Codership, open source
database cluster known for its auto healing, HA ,
distributed, scalable properties.
Compatible with MySQL, MariaDB and Percona
XtraDB
True parallel replication, on row level
Active-active multi-master topology
FEATURES OF GALERA CLUSTER
Synchronous replication
Read and write to any cluster node
Automatic membership control
Automatic node joining
True parallel replication, on row level
ADVANTAGES OVER MYSQL REPLICATION
No slave lag
Read and write scalability
Less manual effort to recover in case of
failures
Guaranteed write consistency
HOW IT WORKS?
GTID: Combination of state UUID and ordinal
sequence number
Certification based replication
Write-Set rep API
SST-IST: StateSnapshotTransfer /
IncrementalStateTransfer
SAMPLE GALERA CLUSTER SETUP
Galera Cluster
DB1 DB3DB2
HAPROXY/Load Balancer
MULTI MASTER REPLICATION VS GALERA
CLUSTER
Parameters Master-Master Galera Cluster
DDL
Bring instance out of loop and
execute DDLs Total order isolation, rolling schema upgrade
Auto_Increment
Based on no. of instances
configured in master-master
Auto increment values are not sequential for
avoiding conflicts values may have gaps
Automatic
Failover No automatic failover Auto failover
Backups
Backups can be taken from
dedicated backup slave STATE snapshot transfer as backup
Table Level LocksAvailable Table level locks are not supported
Functions
All functions supported but may
cause data discrepancy in case of
non-deterministic functions
Non-Deterministic functions like now() are
not supported
MIGRATING FROM M-M TO GALERA
InnoDB Engine
No explicit table locks are allowed
Mandatory primary key/delete is not allowed
No application login based on
auto_increment values
Conflicting updates should be sent to one
node
PERFORMANCE BENCHMARK GALERA CLUSTER VS
MULTI MASTER REPLICATION
Configuration used for Benchmarking
Parameter Galera M-M Replication
No of Nodes 3 2
Memory(Innodb) 122M 122M
Slave Threads 8 8
SST Method Rsync NA
No of Tables 10 10
No of Rows Per Table 2000000 2000000
Time Taken 60 secs for each iteration 60 secs for each iteration
*One transaction consists of 14 selects, 2 updates, 1 delete and 1 insert
Reads
Concurrent Threads Read Queries (Galera) Read Queries (M-M)
1 112602 21840
2 138068 27846
4 150234 36792
8 152054 49518
16 154518 68642
32 155988 77350
64 155624 89152
128 154672 97916
256 160930 100128
512 158438 105840
Writes
Concurrent Threads Write Queries(Galera) Write Queries(M-M)
1 32172 6240
2 39448 7956
4 42924 10512
8 43444 14148
16 44148 19612
32 44568 22100
64 44464 25472
128 44191 27976
256 45979 28608
512 45268 30240
Transactions Per Second
Concurrent Threads TransactionsG/sec TransactionsM/sec
1 133 26
2 164 33
4 178 43
8 179 58
16 183 58
32 184 81
64 182 105
128 180 114
256 187 116
512 181 120
Read/Write Requests Per Second
Concurrent Threads Read/Write RequestsG/sec Read/Write RequestsM/sec
1 2410 467
2 2955 595
4 3207 787
8 3233 1056
16 3305 1465
32 3317 1652
64 3294 1901
128 3253 2066
256 3381 2102
512 3285 2171
Response Time in milliseconds
Threads Response TimeG(Milisecond) Response TimeM(Milisecond)
1 7.46 38.46
2 12.18 60.38
4 22.41 91.38
8 44.47 135.89
16 87.08 196.27
32 173.31 348.11
64 347.54 604.31
128 707.11 1108.43
256 1345.56 2172.53
512 2793.23 4168.38
Thanks

[@NaukriEngineering] Introduction to Galera cluster

  • 1.
    INTRODUCTION TO GALERACLUSTER -GARIMA MASAND
  • 2.
    SHORTCOMINGS OF MYSQLREPLICATION Asynchronous: may result in data loss Single Threaded: slave lag, performance penalty Master-Slave: read-write segregation on application level Master-Master: inconsistent data in case of failures/no automated failover High Availability: manual intervention required for traffic shifting
  • 3.
    HOW CAN WEOVERCOME THEM?
  • 4.
  • 5.
    WHAT IS GALERA? Galera DB1DB3DB2 Galera is a brainchild of Codership, open source database cluster known for its auto healing, HA , distributed, scalable properties. Compatible with MySQL, MariaDB and Percona XtraDB True parallel replication, on row level Active-active multi-master topology
  • 6.
  • 7.
    Synchronous replication Read andwrite to any cluster node Automatic membership control Automatic node joining True parallel replication, on row level
  • 8.
    ADVANTAGES OVER MYSQLREPLICATION No slave lag Read and write scalability Less manual effort to recover in case of failures Guaranteed write consistency
  • 9.
    HOW IT WORKS? GTID:Combination of state UUID and ordinal sequence number Certification based replication Write-Set rep API SST-IST: StateSnapshotTransfer / IncrementalStateTransfer
  • 10.
    SAMPLE GALERA CLUSTERSETUP Galera Cluster DB1 DB3DB2 HAPROXY/Load Balancer
  • 11.
    MULTI MASTER REPLICATIONVS GALERA CLUSTER Parameters Master-Master Galera Cluster DDL Bring instance out of loop and execute DDLs Total order isolation, rolling schema upgrade Auto_Increment Based on no. of instances configured in master-master Auto increment values are not sequential for avoiding conflicts values may have gaps Automatic Failover No automatic failover Auto failover Backups Backups can be taken from dedicated backup slave STATE snapshot transfer as backup Table Level LocksAvailable Table level locks are not supported Functions All functions supported but may cause data discrepancy in case of non-deterministic functions Non-Deterministic functions like now() are not supported
  • 12.
    MIGRATING FROM M-MTO GALERA InnoDB Engine No explicit table locks are allowed Mandatory primary key/delete is not allowed No application login based on auto_increment values Conflicting updates should be sent to one node
  • 13.
    PERFORMANCE BENCHMARK GALERACLUSTER VS MULTI MASTER REPLICATION Configuration used for Benchmarking Parameter Galera M-M Replication No of Nodes 3 2 Memory(Innodb) 122M 122M Slave Threads 8 8 SST Method Rsync NA No of Tables 10 10 No of Rows Per Table 2000000 2000000 Time Taken 60 secs for each iteration 60 secs for each iteration *One transaction consists of 14 selects, 2 updates, 1 delete and 1 insert
  • 14.
    Reads Concurrent Threads ReadQueries (Galera) Read Queries (M-M) 1 112602 21840 2 138068 27846 4 150234 36792 8 152054 49518 16 154518 68642 32 155988 77350 64 155624 89152 128 154672 97916 256 160930 100128 512 158438 105840
  • 15.
    Writes Concurrent Threads WriteQueries(Galera) Write Queries(M-M) 1 32172 6240 2 39448 7956 4 42924 10512 8 43444 14148 16 44148 19612 32 44568 22100 64 44464 25472 128 44191 27976 256 45979 28608 512 45268 30240
  • 16.
    Transactions Per Second ConcurrentThreads TransactionsG/sec TransactionsM/sec 1 133 26 2 164 33 4 178 43 8 179 58 16 183 58 32 184 81 64 182 105 128 180 114 256 187 116 512 181 120
  • 17.
    Read/Write Requests PerSecond Concurrent Threads Read/Write RequestsG/sec Read/Write RequestsM/sec 1 2410 467 2 2955 595 4 3207 787 8 3233 1056 16 3305 1465 32 3317 1652 64 3294 1901 128 3253 2066 256 3381 2102 512 3285 2171
  • 18.
    Response Time inmilliseconds Threads Response TimeG(Milisecond) Response TimeM(Milisecond) 1 7.46 38.46 2 12.18 60.38 4 22.41 91.38 8 44.47 135.89 16 87.08 196.27 32 173.31 348.11 64 347.54 604.31 128 707.11 1108.43 256 1345.56 2172.53 512 2793.23 4168.38
  • 19.