In this post, I ‘ m going to cover my recent encounter with MaxScale. We had to help one of our client to load balance and split read / writes on their 3 node Percona XtraDB Cluster (PXC).
List of available options were
Implementation of HaProxy is ruled out as It’s doesn’t have SQL awareness, Also PXC don’t scale well on write sharing.
“In the past, Read Write split has to done on the application side using API’s. Now, we can able to split Reads and Writes without touching application through Intelligent Load Balancers”
Finally, We have chosen MaxScale over ProxySQL as ProxySQL is still in Beta and not as feature rich as MaxScale & Galera Support was not ready completely.
Key Reason To Choose MaxScale:
- SQL aware load balancer – Can able to split the reads / writes
- Galera state awareness – Can able to direct hits only to the nodes in ‘Synced’ state in PXC
- Modular implementation – Easier to Implment, Use and Manage
- Monitoring console – We can login MaxScale console to verify the states and routing statistics
- Actively maintained by MariaDB Corp – It has GA release from MariaDB and You can expect prompt fixes and upgrades.
Implementation:
1. Pre Requisite
Create a MySQL user with the following privileges on db servers to be able to connect from MaxScale server, To check states and availability.
2. Download and Install MaxScale
MariaDB MaxScale’s packages are available at https://downloads.mariadb.com/files/MaxScale
Here I ‘ m downloading and installing the MaxScale’s latest version 1.4.3.
3. Setup MaxScale Config
MaxScale looks for configuration file at /etc/maxscale.cnf
MaxScale has modular implementation and you need understand the following terms to setup MaxScale config.
[i] Monitor – MaxScale will analyse the given servers internally at regular intervals based on the given monitor modules. Basic modules are explained below.
“mysqlmon” – Check native replication health and server states (Master or Slave).
“galeramon” – Galera cluster health and node states are monitored with module.
We have used “galeramon” to monitor our PXC cluster. Sample config is listed below.
[ii] Balance Load – MaxScale route connections based on router algorithm specified. Basic router types are explained below.
“readwritesplit” – To split the incoming writes to a single master and reads to the any number of given slaves.
“readconnroute” – It will split the incoming connections with round robin mechanism.
“cli” – MaxScale monitoring console.
We have used “readwritesplit” to split the reads / writes. Sample config is listed below.
Config for monitoring console is listed
[iii] Listen – MaxScale needs a listener to accept incoming connections for each service defined
[iv] Define Nodes – We have to define the node ip, port for the servers.
Similarly define the server details for node2 and node3
Now put the snippets altogether on /etc/maxscale.cnf
4. Start MaxScale
MaxScale config is compelete on the previous step. Now, We can start MaxScale.
Check MaxScale log “/var/log/maxscale/maxscale1.log” In case of errors in Start.
5. Verify Implementation
This completes installation of MaxScale. Operations and Administration will be followed up on later part of the blog post.