In the past, when using other database middleware, we used LVS+KP or F5. I see that the TiDB documentation has a best practice: HAProxy Best Practices in TiDB
It only introduces the installation of HAProxy without combining it with KP or similar tools. The actual situation shouldn’t be like this, right?
I’ve always heard about HAProxy but never actually used it. I hope experienced friends can share their insights, and having related documentation would be even better.
Just add a keepalive and use VIP as the load balancing address. This way, if any haproxy encounters an issue, high availability service can still be provided through the VIP.
If you want to be cautious, use keepalived + haproxy. However, the downside of haproxy as a proxy is that if one of the backend TiDB nodes goes down, users will need to reconnect. It is not seamless. The advantage is that it is mature and reliable.
If it’s for experimentation or testing, the official bot posted a very interesting video on Bilibili.
In the video, the proxy used is tiproxy, which is also similar to the keepalived + tiproxy solution. From the demonstration, it seems that several backend TiDB nodes can go down without the client noticing. This is very cool.
Additionally, I have experimented with TiDB 7.1 + ProxySQL 2.5.2.
ProxySQL works well as a proxy for MySQL, but when used as a proxy for TiDB, some SQL queries result in errors while others do not. Due to my limited skills, I couldn’t figure out the issue, so I abandoned this combination.
TiDB itself is stateless. Could the official team develop a component to implement HAproxy keepalive functionality to achieve VIP? I think this is very necessary, so customers don’t have to deploy additional components themselves.