I've set up Maxscale to ReadWriteSplit with no reads to master (the default) to a Galera cluster (3 nodes).
#
# Global configuration
#
[maxscale]
threads=auto
local_address=10.1.0.11
query_retries=2
#
# Servers
#
[sql1]
type=server
address=10.1.0.2
port=3306
protocol=MariaDBBackend
persistpoolmax=16
persistmaxtime=300s
priority=1
ssl=required
ssl_ca_cert=/var/lib/maxscale/ssl/ca-cert.pem
ssl_cert=/var/lib/maxscale/ssl/client.pem
ssl_key=/var/lib/maxscale/ssl/client.key
[sql2]
type=server
address=10.1.0.3
port=3306
protocol=MariaDBBackend
persistpoolmax=16
persistmaxtime=300s
priority=2
ssl=required
ssl_ca_cert=/var/lib/maxscale/ssl/ca-cert.pem
ssl_cert=/var/lib/maxscale/ssl/client.pem
ssl_key=/var/lib/maxscale/ssl/client.key
[sql3]
type=server
address=10.1.0.4
port=3306
protocol=MariaDBBackend
persistpoolmax=16
persistmaxtime=300s
priority=3
ssl=required
ssl_ca_cert=/var/lib/maxscale/ssl/ca-cert.pem
ssl_cert=/var/lib/maxscale/ssl/client.pem
ssl_key=/var/lib/maxscale/ssl/client.key
#
# Monitor
#
[monitor]
type=monitor
module=galeramon
servers=sql1,sql2,sql3
user=maxscale
password=324F7B3BE796AD5F4BB2FAD65E1F9052A976701742729400
available_when_donor=true
use_priority=true
#
# Listeners
#
[listener-rw]
type=listener
service=readwritesplit
protocol=MariaDBClient
address=10.1.0.1
port=3306
ssl=required
ssl_ca_cert=/var/lib/maxscale/ssl/ca-cert.pem
ssl_cert=/var/lib/maxscale/ssl/server.pem
ssl_key=/var/lib/maxscale/ssl/server.key
#
# Services
#
[readwritesplit]
type=service
router=readwritesplit
servers=sql1,sql2,sql3
user=maxscale
password=324F74A347291B3BE79956AD5F4BB917701742729400
enable_root_user=1
max_sescmd_history=150
While testing some read queries using loader.io I always get the same number of connection across all nodes:
> maxctrl list servers
┌────────┬───────────┬──────┬─────────────┬─────────────────────────┬───────────────────────────────┐
│ Server │ Address │ Port │ Connections │ State │ GTID │
├────────┼───────────┼──────┼─────────────┼─────────────────────────┼───────────────────────────────┤
│ sql1 │ 10.1.0.2 │ 3306 │ 87 │ Master, Synced, Running │ 0-1-12474939,1-1-148225,2-2-2 │
├────────┼───────────┼──────┼─────────────┼─────────────────────────┼───────────────────────────────┤
│ sql2 │ 10.1.0.3 │ 3306 │ 87 │ Slave, Synced, Running │ 0-2-410,2-2-2 │
├────────┼───────────┼──────┼─────────────┼─────────────────────────┼───────────────────────────────┤
│ sql3 │ 10.1.0.4 │ 3306 │ 87 │ Slave, Synced, Running │ 2-2-2 │
└────────┴───────────┴──────┴─────────────┴─────────────────────────┴───────────────────────────────┘
Shouldn't i expect to see a high number of connections on nodes 2 and 3 (slaves) and a slow number on node 1?
By default readwritesplit creates a connection to all nodes. You need to define max_slave_connections=1
to have it create only one slave connection.