Question about backend load balancing within a hostgroup

I’m very new to proxysql and have been testing out how proxysql load balances traffic within a host group. In my case I don’t want a server shunned in the event it goes above a certain threshold of replication lag so I have max lag set to 0. However I would expect that proxysql would route traffic to the server in the hostgroup with the least lag, but that doesn’t seem to be happening. I have two servers in hostgroup 1 and a query rule with a match pattern of .* that routes to hostgroup 1. When I create lag on one of the servers then run a test query of select @@hostname; it will sometimes route the query to the server with lag and not to the server with no lag.

I haven’t seen anything in the documentation on how to control where the hostgroup manager routes the queries. Is there some way to configure it to do lag based routing without having it shun a server?

Thanks in advance

1 Like

I believe you’re looking for ProxySQL GTID consistent reads feature. You can read more about it here https://proxysql.com/blog/proxysql-gtid-causal-reads/. What kind of backend cluster do you have (eg PXC/Galera, InnoDB Cluster, async source/replica)?