Galera Cluster Performance
Luke Hebert
- 2 minutes read - 332 wordsGalera Cluster performance can be improved by adjusting the write-set cache (gcache) and its page size. When the cache is too small, Galera falls back to reading write-sets from disk, which adds latency to every replicated transaction. Bumping these two values is one of the simplest wins you can make on a busy cluster.
Why gcache Matters
The gcache stores recent write-sets in memory so that nodes can apply replicated transactions without hitting disk. The two key parameters are:
- gcache.size – total size of the write-set cache (default: 256M)
- gcache.page_size – size of each page within the cache (default: 128M)
If your workload generates a high volume of writes, the default 256M cache will fill up quickly. You will see warnings in the error log like gcache is too small and a noticeable increase in disk I/O.
Recommended Configuration
For clusters handling moderate to heavy write traffic, a 4G cache with 1G pages gives Galera plenty of headroom while keeping memory usage predictable:
wsrep_provider_options="gcache.size=4G; gcache.page_size=1G"Place this line in your my.cnf (or the relevant MySQL configuration file) under the [mysqld] section, then restart the MySQL service on each node.
Sizing Tips
- Start with at least 1G of gcache for production workloads; scale up if you still see disk reads under load.
- Keep
gcache.page_sizeat roughly 25% ofgcache.sizeas a starting point. - Monitor the
wsrep_local_recv_queueandwsrep_local_send_queuestatus variables after the change to confirm replication queues are draining cleanly. - Make sure the host has enough free RAM to cover the cache plus your InnoDB buffer pool and OS page cache.
Verifying the Change
After a restart, confirm the new values are active:
SHOW VARIABLES LIKE 'wsrep_provider_options';You should see the updated gcache.size and gcache.page_size values in the output. Watch the error log for a few hours to make sure the gcache is too small warnings have stopped appearing.
A small configuration tweak like this can shave meaningful latency off replicated writes, and it takes only a few minutes to apply.