Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: Haproxy负载Tidb数据库如何测试
[TiDB Usage Environment] Production Environment
[TiDB Version] V7.1.1
[Reproduction Path] Using Haproxy for database load balancing, both the load and cluster services have started successfully. However, when testing the balancing rules with relevant commands, the results are not as expected. I’m not sure about the reason or how to test it properly.
[Encountered Issue: Phenomenon and Impact]
[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]
Self-test result:
Expected result:
Are you unsure about which node to connect to?
haproxy configuration, after connecting, check the number of connections in TiDB to know which machine you are connected to.
What you want to ask is whether you don’t know which node to connect to?
Your SQL query indeed doesn’t work, here’s an SQL query for you:
select instance from INFORMATION_SCHEMA.CLUSTER_PROCESSLIST where id=(select connection_id());
How do you check the number of connections in the configuration file? Isn’t this set before startup? Also, mine is the same as the official one, I just changed an IP.
My configuration is:
After replacing my SQL with yours and executing it multiple times, why does it always show the same type of machine? Is it because my strategy is the least number of connections? Since I just created the cluster and it is not in use, each database should have no connections. If they are all 0, shouldn’t it round-robin the connections?
Yes, after executing the command multiple times in the console, check what the polling strategy is. After replacing my SQL with yours and executing it multiple times, why does it always show the same machine? Is it because my strategy is the least number of connections? Because I just created the cluster and it is not in use yet.
How many connections did you open? Don’t close the previous connections, open dozens of windows to see how they are connected.
It seems that your testing method has a problem. Closing connections means that for haproxy, the number of connections is 0 every time you connect.
After logging into MySQL, don’t exit. Open a new window to continue logging in, and then check each connection.
In the HAProxy configuration file, the listen admin_stats
and stats uri
settings allow you to log in and monitor the connection status.
Yes, I made a mistake. The IP returned by executing multiple instances in the same window is different. Initially, it was my mistake.
Well, I’m not clear about the specific meaning of the panel parameters right now. I’ll research it later.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.