Depending on the chosen routing and authentication method, the selection of the Primary or Replica node
can be controlled by the use of the
qos (Quality Of Service) syntax as outlined below:
This setting enables the connector to redirect the query as if it were read-only, and therefore prefer a Replica over a Primary, but will choose a Primary if no Replica is available.
This setting indicates that the query is a write and should be directed to a Primary. In Active-Active setups, where multiple Primaries exist, affinity determines in which site the primary should be selected.
Configuring the use of these properties can be controlled in a number of ways, as follows:
SQL Based Routing (See Section 7.4.11, “SQL Routing”)
Host based Routing (See Section 7.4.12, “Host-based Routing”)
Embedded as part of Schema Name when specifying the database to connect to.
For example, the following connect string would prefer a Replica for its connection:
Further, connectivity can be influenced by setting a suitable latency (See Section 7.4.4, “Specifying Required Latency”) value, or an explicit affinity (See Section 7.4.5, “Setting Read Affinity and Direct Reads”.
The rules for selection of whether a connection is made to a Primary or a Replica is therefore controlled by comparing all of these settings and the selected routing mechanism together.
|QoS||Primary Selected||Replica Selected|
||Only if no Replica available||Yes, if below max applied latency.|
For further reading on how nodes are chosen, see Section 7.4.3, “Connector Load Balancers”