[MXS-4635] Provide load balancing metadata to connectors Created: 2023-06-09 Updated: 2023-11-11 Resolved: 2023-07-13 |
|
| Status: | Closed |
| Project: | MariaDB MaxScale |
| Component/s: | Protocol |
| Affects Version/s: | None |
| Fix Version/s: | 23.08.0 |
| Type: | New Feature | Priority: | Major |
| Reporter: | markus makela | Assignee: | markus makela |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Attachments: |
|
||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||
| Sprint: | MXS-SPRINT-186 | ||||||||||||||||||||
| Description |
|
By adding load related metadata to the login requests, the connectors can make more educated guesses as to where to connect next. This would work well with the MariaDB connectors that support multiple endpoints and would allow a more even load distribution. |
| Comments |
| Comment by Diego Dupin [ 2023-06-09 ] |
|
A solution would be to have some new "Session change type" SESSION_CONNECTION_COUNTER : When establishing a connection to maxscale, maxscale can send to connectors current number of connection in connection creation ending OK_Packet. When using loadbalancing, connector could by default use a round-robin pattern and when having those informations, will connect to the less use maxscale by default. The advantage is when a failover occurs, and that maxscale is up again, connectors will then priorize new connections creation to this maxscale until number of connections reach other's. |
| Comment by markus makela [ 2023-06-09 ] |
|
Another option is to do what is planned for |
| Comment by Diego Dupin [ 2023-06-09 ] |
|
Exactly, I was wondering how far this should be carried by connectors or maxscale. in fact the second solution seems more appropriate |
| Comment by markus makela [ 2023-06-14 ] |
|
This should be straightforward to implement:
A preliminary name for the variable could be _connections. This could also be used by the MariaDB server to indicate how many connections there are. This would give the connectors more information that they could base their load balancing decisions on. Once this is implemented, implementing an initial version of the redirection mechanism described in |
| Comment by markus makela [ 2023-06-22 ] |
|
Attached a proof-of-concept patch for fake status changes for threads_connected (a status variable in MariaDB) which contains the number of current connections. I also added a version of the redirection URL into it since it was trivial to implement once the session state change tracker was done. |
| Comment by Sergei Golubchik [ 2023-06-28 ] |
|
I'd rather do it on the server. It could set redirect_url when the number of connections grow above certain limit |
| Comment by markus makela [ 2023-07-06 ] |
|
MaxScale will now by default send the same values that are set as the default values of session_track_system_variables in the first OK packet: character_set_client, character_set_connection, character_set_results, time_zone. Additionally, the system_time_zone, max_allowed_packet and tx_isolation values are sent as well. The current connection count is also added as threads_connected along with the 64-bit connection ID as connection_id. The autocommit value is not sent since it's redundant as one of the server status bits is reserved for it. |