Are you going in production with Galera Cluster for MySQL? Here are 9 tips to consider before going live. These are applicable to all 3 Galera versions (Codership, Percona XtraDB Cluster and MariaDB Galera Cluster).
1. Galera strengths and weaknesses
There are multiple types of replication and cluster technologies for MySQL, make sure you understand how Galera works so you set the right expectations. Applications that run on single instance MySQL might not work well on Galera, you might need to make some changes to the application or the workload might not be appropriate. We’d suggest you have a look at these resources:
- Tutorial on Galera Cluster
- Is Synchronous Replication Right for your App
- MariaDB Galera Cluster - Known Limitations
- Webinar: Migrating to Galera Cluster
2. Database schema
Synchronous replication has implications on how well some transactions will run, so consider the following:
- Each table must have at least one explicit primary key defined.
- Each table must run under InnoDB or XtraDB storage engine.
- Chunk up your big transaction in batches. For example, rather than having one transaction insert 100,000 rows, break it up into smaller chunks of e.g., insert 1000 rows per transaction.
- Your application can tolerate non-sequential auto-increment values.
- Schema changes are handled differently. Watch this webinar for details.
- Handle hotspots/Galera deadlocks by sending writes to a single node.
3. Hardware and network
Galera will perform as fast as the slowest node. This is due to the nature of synchronous replication, where all nodes need to acknowledge a writeset before committing. Choosing uniform hardware for all nodes is recommended. If you’re running on virtualized environments, monitor CPU Steal Time (the percentage of time a virtual CPU waits for a real CPU while the hypervisor is servicing another virtual processor).
The disk subsystem is important (and also applies to single instance MySQL). Remember that upgrading the disk layer is a bigger hassle than upgrading the other components like RAM or network interface card. Hardware upgrades can be performed in round-robin fashion, i.e upgrading one node at a time.