SlideShare a Scribd company logo
Using Galera Cluster to Power
Geo-distributed Applications on the WAN
Philip Stoev
Codership
Galera Replication Plugin
Clients
WSREP APIWSREP APIWSREP API
MySQL MySQL MySQL
Galera Replication Plugin
Clients
WSREP APIWSREP APIWSREP API
MySQL MySQL MySQL
1 km
or 10000 km
Geo-distribution And Scaling
node
1
node
4
node
2
node
3
Why WAN replication?
● Go beyond availability zones and achieve multi-data center
redundancy
– multiple availability zones can fail at the same time
● Span multiple cloud providers
● Bring data closer to application
● Distribute global data globally
– OpenStack's Keystone and Glance databases
Bring The Data Closer
● Most queries are read-only anyway
– answer them from an up-to-date, local copy of the database
● Caching at its finest
– InnoDB buffer pool takes care of the caching part
– Galera takes care of “invalidation”, so data is always fresh
– Single global “source-of-truth” database
● Most round-trip times are due to the MySQL client protocol
– slash them all except at COMMIT
Dedicated Features for WAN Replication
● Galera works across and between continents
– minimal latency penalty / number of messages exchanged
● No or minimal slave lag
● Optimizations reduce cross-data center traffic
– updates are sent only once per data center
– new nodes get initial database from close neighbor
● Encryption
● Detection and automatic eviction of unreliable nodes
Basic Configuration
● Specify network location for each node
– set gmcast.segment=X in wsrep_provider_options
● Open Firewall
– Galera uses ports 3306, 4567, 4568 and 4444
– should be open both ways as any node can contact any other node
● Configure IPs
– set wsrep_node_addres, wsrep_cluster_address with public IPs
– or use a DNS name that resolves appropriately from any node
Security First
● Securing Galera replication traffic and IST
– set
socket.ssl_key, socket.ssl_cert, socket.ssl_ca
in
wsrep_provider_options
● SST is secured separately
● VPN works too
– but watch out for flow control and fragmentation
Securing SST
SST must be secured separately depending on SST method
● rsync
– add CAfile, cert, key to /etc/stunnel/stunnel.conf
● mysqldump
– CREATE USER sst_user … REQUIRE SSL
– add ssl-ca, ssl-key, ssl-cert to [mysql] in my.cnf
● xtrabackup
– add tkey, tcert, encrypt=3 to [SST] in my.cnf
Configuring TCP for Performance
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_slow_start_after_idle = 0
Configuring Galera for Performance
● Avoid fragmentation at binlog level:
– binlog-row-event-max-size = 1048576
● Avoid flow control and fragmentation at Galera level:
– wsrep_provider_options="
gcs.max_packet_size=1048576;
evs.send_window=512; evs.user_send_window=256"
● Disable InnoDB flush to disk:
– set innodb_flush_log_at_trx_commit = 0
– node failures are considered independent
Achieving Reliability
How do I get the benefits of synchronous WAN replication but
avoid blocking if there is a network problem?
Have and almost eat it too
Avoid Split-Brain
● Use an odd number of data centers
● If two data centers, one should be designated primary:
– run a Galera arbitrator there
– run a larger number of nodes
– use pc.weight in wsrep_provider_options to affect quorum
calculation
Configure Timeouts
● Review default values for:
– evs.inactive_timeout=PT15S
– evs.suspect_timeout=PT5S
●
Set up auto-eviction:
– node will be evicted if it repeatedly suffers network issues
– it will not be allowed to rejoin without a manual intervention
A Latency Example
● EC2 in Nortern Virginia, Sydney and São Paulo (2 nodes)
● Latencies 238 ms, 119 ms and 316 ms
# Inserting from Sydney:
mysql> insert into t1 values (REPEAT('a',1000));
Query OK, 1 row affected (0.35 sec)
# Inserting from São Paulo #1
mysql> insert into t1 values (REPEAT('a',1000));
Query OK, 1 row affected (0.35 sec)
Blobs
● 2.5 Mb worth of data in 5 blobs 512K each
mysql> INSERT INTO t2 VALUES (REPEAT('a', 512 * 1024)),(REPEAT('a',
512 * 1024)),(REPEAT('a', 512 * 1024)),(REPEAT('a', 512 * 1024)),
(REPEAT('a', 512 * 1024));
Query OK, 5 rows affected (0.67 sec)
Thank you
Questions?
Weird setups you want to try out?
Have one node on the moon?
And another on a Raspberry PI?
philip.stoev@galeracluster.com

More Related Content

ODP
Do more with Galera Cluster in your OpenStack cloud
PPT
Using galera replication to create geo distributed clusters on the wan
PDF
Scaling with sync_replication using Galera and EC2
PDF
Introduction to Galera Cluster
PDF
合并到 XtraDB 存储引擎集群
PDF
Using galera replication to create geo distributed clusters on the wan
PDF
Galera explained 3
PPT
Galera Cluster Best Practices for DBA's and DevOps Part 1
Do more with Galera Cluster in your OpenStack cloud
Using galera replication to create geo distributed clusters on the wan
Scaling with sync_replication using Galera and EC2
Introduction to Galera Cluster
合并到 XtraDB 存储引擎集群
Using galera replication to create geo distributed clusters on the wan
Galera explained 3
Galera Cluster Best Practices for DBA's and DevOps Part 1

What's hot (20)

PDF
Introduction to Galera
PPTX
ProxySQL for MySQL
PDF
How to understand Galera Cluster - 2013
PPT
Taking Full Advantage of Galera Multi Master Cluster
PPT
MySQL HA Percona cluster @ MySQL meetup Mumbai
PDF
Webinar slides: Introducing Galera 3.0 - Now supporting MySQL 5.6
DOCX
Master master vs master-slave database
PPTX
C* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag Jambhekar
PDF
Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski...
PDF
Galera Cluster 3.0 Features
PPT
Webinar: Getting Started with Apache Cassandra
PDF
Zero Downtime Schema Changes - Galera Cluster - Best Practices
PPTX
Ansible for large scale deployment
PDF
Client Drivers and Cassandra, the Right Way
PPTX
Maria DB Galera Cluster for High Availability
PDF
Tuning Speculative Retries to Fight Latency (Michael Figuiere, Minh Do, Netfl...
PPTX
One Tool to Rule Them All- Seamless SQL on MongoDB, MySQL and Redis with Apac...
PDF
Plny12 galera-cluster-best-practices
PDF
Micro-batching: High-performance writes
Introduction to Galera
ProxySQL for MySQL
How to understand Galera Cluster - 2013
Taking Full Advantage of Galera Multi Master Cluster
MySQL HA Percona cluster @ MySQL meetup Mumbai
Webinar slides: Introducing Galera 3.0 - Now supporting MySQL 5.6
Master master vs master-slave database
C* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag Jambhekar
Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski...
Galera Cluster 3.0 Features
Webinar: Getting Started with Apache Cassandra
Zero Downtime Schema Changes - Galera Cluster - Best Practices
Ansible for large scale deployment
Client Drivers and Cassandra, the Right Way
Maria DB Galera Cluster for High Availability
Tuning Speculative Retries to Fight Latency (Michael Figuiere, Minh Do, Netfl...
One Tool to Rule Them All- Seamless SQL on MongoDB, MySQL and Redis with Apac...
Plny12 galera-cluster-best-practices
Micro-batching: High-performance writes
Ad

Similar to Using Galera Cluster to Power Geo-distributed Applications on the WAN (20)

PDF
Using galera replication to create geo distributed clusters on the wan
PDF
MySQL Galera 集群
PPTX
Migrating to XtraDB Cluster
PDF
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
PDF
Galera Cluster 4 for MySQL 8 Release Webinar slides
PPTX
Migrating to XtraDB Cluster
PDF
FOSDEM 2012: MySQL synchronous replication in practice with Galera
PDF
Highly Available Load Balanced Galera MySql Cluster
PDF
Galera Cluster 4 presentation at Percona Live Austin 2019
PDF
What’s new in Galera 4
PDF
Galera cluster for high availability
PDF
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera Cluster
PPT
Codership's galera cluster installation and quickstart webinar march 2016
PPT
Codership's galera cluster installation and quickstart webinar march 2016
PPT
Codership's galera cluster installation and quickstart webinar march 2016
PDF
Robust ha solutions with proxysql
PDF
Webinar slides: Migrating to Galera Cluster for MySQL and MariaDB
PDF
MariaDB Galera Cluster webinar — 2025 Edition.pdf
PDF
Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...
PDF
M|18 Under the Hood: Galera Cluster
Using galera replication to create geo distributed clusters on the wan
MySQL Galera 集群
Migrating to XtraDB Cluster
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
Galera Cluster 4 for MySQL 8 Release Webinar slides
Migrating to XtraDB Cluster
FOSDEM 2012: MySQL synchronous replication in practice with Galera
Highly Available Load Balanced Galera MySql Cluster
Galera Cluster 4 presentation at Percona Live Austin 2019
What’s new in Galera 4
Galera cluster for high availability
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera Cluster
Codership's galera cluster installation and quickstart webinar march 2016
Codership's galera cluster installation and quickstart webinar march 2016
Codership's galera cluster installation and quickstart webinar march 2016
Robust ha solutions with proxysql
Webinar slides: Migrating to Galera Cluster for MySQL and MariaDB
MariaDB Galera Cluster webinar — 2025 Edition.pdf
Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...
M|18 Under the Hood: Galera Cluster
Ad

Recently uploaded (20)

PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Nekopoi APK 2025 free lastest update
PPTX
L1 - Introduction to python Backend.pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
System and Network Administraation Chapter 3
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Digital Strategies for Manufacturing Companies
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Transform Your Business with a Software ERP System
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Essential Infomation Tech presentation.pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Reimagine Home Health with the Power of Agentic AI​
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Nekopoi APK 2025 free lastest update
L1 - Introduction to python Backend.pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
How Creative Agencies Leverage Project Management Software.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
System and Network Administraation Chapter 3
Which alternative to Crystal Reports is best for small or large businesses.pdf
Digital Strategies for Manufacturing Companies
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Navsoft: AI-Powered Business Solutions & Custom Software Development
Adobe Illustrator 28.6 Crack My Vision of Vector Design
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Transform Your Business with a Software ERP System
Design an Analysis of Algorithms I-SECS-1021-03
Essential Infomation Tech presentation.pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Reimagine Home Health with the Power of Agentic AI​

Using Galera Cluster to Power Geo-distributed Applications on the WAN

  • 1. Using Galera Cluster to Power Geo-distributed Applications on the WAN Philip Stoev Codership
  • 2. Galera Replication Plugin Clients WSREP APIWSREP APIWSREP API MySQL MySQL MySQL
  • 3. Galera Replication Plugin Clients WSREP APIWSREP APIWSREP API MySQL MySQL MySQL 1 km or 10000 km
  • 5. Why WAN replication? ● Go beyond availability zones and achieve multi-data center redundancy – multiple availability zones can fail at the same time ● Span multiple cloud providers ● Bring data closer to application ● Distribute global data globally – OpenStack's Keystone and Glance databases
  • 6. Bring The Data Closer ● Most queries are read-only anyway – answer them from an up-to-date, local copy of the database ● Caching at its finest – InnoDB buffer pool takes care of the caching part – Galera takes care of “invalidation”, so data is always fresh – Single global “source-of-truth” database ● Most round-trip times are due to the MySQL client protocol – slash them all except at COMMIT
  • 7. Dedicated Features for WAN Replication ● Galera works across and between continents – minimal latency penalty / number of messages exchanged ● No or minimal slave lag ● Optimizations reduce cross-data center traffic – updates are sent only once per data center – new nodes get initial database from close neighbor ● Encryption ● Detection and automatic eviction of unreliable nodes
  • 8. Basic Configuration ● Specify network location for each node – set gmcast.segment=X in wsrep_provider_options ● Open Firewall – Galera uses ports 3306, 4567, 4568 and 4444 – should be open both ways as any node can contact any other node ● Configure IPs – set wsrep_node_addres, wsrep_cluster_address with public IPs – or use a DNS name that resolves appropriately from any node
  • 9. Security First ● Securing Galera replication traffic and IST – set socket.ssl_key, socket.ssl_cert, socket.ssl_ca in wsrep_provider_options ● SST is secured separately ● VPN works too – but watch out for flow control and fragmentation
  • 10. Securing SST SST must be secured separately depending on SST method ● rsync – add CAfile, cert, key to /etc/stunnel/stunnel.conf ● mysqldump – CREATE USER sst_user … REQUIRE SSL – add ssl-ca, ssl-key, ssl-cert to [mysql] in my.cnf ● xtrabackup – add tkey, tcert, encrypt=3 to [SST] in my.cnf
  • 11. Configuring TCP for Performance net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.rmem_default = 16777216 net.core.wmem_default = 16777216 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 net.ipv4.tcp_slow_start_after_idle = 0
  • 12. Configuring Galera for Performance ● Avoid fragmentation at binlog level: – binlog-row-event-max-size = 1048576 ● Avoid flow control and fragmentation at Galera level: – wsrep_provider_options=" gcs.max_packet_size=1048576; evs.send_window=512; evs.user_send_window=256" ● Disable InnoDB flush to disk: – set innodb_flush_log_at_trx_commit = 0 – node failures are considered independent
  • 13. Achieving Reliability How do I get the benefits of synchronous WAN replication but avoid blocking if there is a network problem? Have and almost eat it too
  • 14. Avoid Split-Brain ● Use an odd number of data centers ● If two data centers, one should be designated primary: – run a Galera arbitrator there – run a larger number of nodes – use pc.weight in wsrep_provider_options to affect quorum calculation
  • 15. Configure Timeouts ● Review default values for: – evs.inactive_timeout=PT15S – evs.suspect_timeout=PT5S ● Set up auto-eviction: – node will be evicted if it repeatedly suffers network issues – it will not be allowed to rejoin without a manual intervention
  • 16. A Latency Example ● EC2 in Nortern Virginia, Sydney and São Paulo (2 nodes) ● Latencies 238 ms, 119 ms and 316 ms # Inserting from Sydney: mysql> insert into t1 values (REPEAT('a',1000)); Query OK, 1 row affected (0.35 sec) # Inserting from São Paulo #1 mysql> insert into t1 values (REPEAT('a',1000)); Query OK, 1 row affected (0.35 sec)
  • 17. Blobs ● 2.5 Mb worth of data in 5 blobs 512K each mysql> INSERT INTO t2 VALUES (REPEAT('a', 512 * 1024)),(REPEAT('a', 512 * 1024)),(REPEAT('a', 512 * 1024)),(REPEAT('a', 512 * 1024)), (REPEAT('a', 512 * 1024)); Query OK, 5 rows affected (0.67 sec)
  • 18. Thank you Questions? Weird setups you want to try out? Have one node on the moon? And another on a Raspberry PI? philip.stoev@galeracluster.com