MXS-2350: Allow lazy connection creation
The lazy connection creation reduces the burden that short sessions place on the backend servers. This also prevents the problems caused by early disconnections that happen when only one server is used but multiple connections are created. This does not solve the problem (MXS-619) but it does mitigate it to acceptable levels. This commit also adds a change to the weighting algorithm that prefers existing connections over unopened ones. This helps avoid the flip-flopping that happens when the absolute scores are very similar. The hard-coded value might need to be tuned once testing is done.
This commit is contained in:
@ -57,6 +57,13 @@ PRWBackends::iterator best_score(PRWBackends& sBackends,
|
||||
for (auto ite = sBackends.begin(); ite != sBackends.end(); ++ite)
|
||||
{
|
||||
double score = server_score((**ite).backend());
|
||||
|
||||
if (!(*ite)->in_use())
|
||||
{
|
||||
// To prefer servers that we are connected to, inflate the score of unconnected servers
|
||||
score = (score + 5.0) * 1.5;
|
||||
}
|
||||
|
||||
if (min > score)
|
||||
{
|
||||
min = score;
|
||||
|
||||
Reference in New Issue
Block a user