2

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?

Paulo Boaventura
  • 1,365
  • 1
  • 9
  • 29
ac_s_fer
  • 53
  • 4

1 Answers1

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.

markusjm
  • 2,358
  • 1
  • 11
  • 23
  • Thanks. If i understand this parameter right, shouldn't I set this to `` so, as I have 2 slaves, have `max_slave_connections=2` ? https://mariadb.com/kb/en/mariadb-maxscale-24-readwritesplit/#max_slave_connections – ac_s_fer Nov 02 '20 at 06:19
  • Also, why does it also creates connections to `master`? I understand connections to `slaves`, but why is `master` involved in `read` queries? – ac_s_fer Nov 02 '20 at 06:39
  • If you want readwritesplit to create connections when it needs them, use the `lazy_connect` parameter. – markusjm Nov 03 '20 at 07:07
  • 1
    Ok thanks, I believe i should just make abstraction of those numbers and feel confident that maxscale is getting out the best of my backends with default configuration ;) – ac_s_fer Nov 06 '20 at 13:53