Skip to content

Latest commit

 

History

History
13 lines (11 loc) · 6.05 KB

ReaderSelectionStrategies.md

File metadata and controls

13 lines (11 loc) · 6.05 KB

Reader Selection Strategies

To balance connections to reader instances more evenly, different selection strategies can be used. The following table describes the currently available selection strategies and any relevant configuration parameters for each strategy.

Reader Selection Strategy Configuration Parameter Description Default Value
random This strategy does not have configuration parameters. The random strategy is the default selection strategy. When switching to a reader connection, the reader instance will be chosen randomly from the available database instances. N/A
leastConnections This strategy does not have configuration parameters. The least connections strategy will select reader instances based on which database instance has the least number of currently active connections. Note that this strategy is only available when internal connection pools are enabled - if you set the connection property without enabling internal pools, an error will be thrown. N/A
roundRobin See the following rows for configuration parameters. The round robin strategy will select a reader instance by taking turns with all available database instances in a cycle. A slight addition to the round robin strategy is the weighted round robin strategy, where more connections will be passed to reader instances based on user specified connection properties. N/A
roundRobinHostWeightPairs This optional parameter value must be a string type comma separated list of database host-weight pairs in the format <host>:<weight>. The host represents the database instance name, and the weight represents how many connections should be directed to the host in one cycle through all available hosts. For example, the value instance-1:1,instance-2:4 means that for every connection to instance-1, there will be four connections to instance-2.

Note: The <weight> value in the string must be an integer greater than or equal to 1.
null
roundRobinDefaultWeight This optional parameter value must be an integer value. This parameter represents the default weight for any hosts that have not been configured with the roundRobinHostWeightPairs parameter. For example, if a connection were already established and host weights were set with roundRobinHostWeightPairs but a new reader host was added to the database, the new reader host would use the default weight.

Note: This value must be an integer greater than or equal to 1.
1
fastestResponse See the following rows for configuration parameters. The fastest response strategy identifies the fastest response host, then stores this host in a cache for future use.

Note: The Fastest Response Strategy plugin must also be loaded into the plugins list by setting the plugins client configuration parameter to include the fastestResponseStrategy plugin code.
responseMeasurementIntervalMs Interval in millis between measuring response time to a database host. 30000