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:
Markus Mäkelä
2019-02-28 21:17:17 +02:00
parent 95317725ce
commit 24ea222ed6
7 changed files with 52 additions and 15 deletions

View File

@ -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;