Prefer servers that are not busy executing session commands

Readwritesplit now prefers servers that are not busy executing session
commands. This should give the best responsiveness for reads.
This commit is contained in:
Markus Mäkelä
2018-06-12 22:16:45 +03:00
parent 70104f957e
commit 1ea94501e4

View File

@ -63,6 +63,19 @@ static SRWBackend compare_backends(SRWBackend a, SRWBackend b, select_criteria_t
return a;
}
// Prefer servers that are not busy executing session commands
bool a_busy = a->has_session_commands();
bool b_busy = b->has_session_commands();
if (a_busy && !b_busy)
{
return b;
}
else if (!a_busy && b_busy)
{
return a;
}
return p(a, b) <= 0 ? a : b;
}