What does everyone use for TiDB server load balancing?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 大家都用什么做tidb server的负载均衡?

| username: 我是咖啡哥

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.

| username: 啦啦啦啦啦 | Original post link

You can check out this article

| username: Anna | Original post link

Configure Load Balancer

| username: zhanggame1 | Original post link

A more cost-effective solution than HAProxy with keepalive is to use an F5 load balancing device.

| username: 我是咖啡哥 | Original post link

I didn’t use containers.

| username: weixiaobing | Original post link

haproxy + keepalive ensures high availability of load balancing, or use load balancers like F5.

| username: 我是咖啡哥 | Original post link

Are there any best practices for haproxy+ keepalive?

| username: weixiaobing | Original post link

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.

| username: 有猫万事足 | Original post link

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.

| username: hey-hoho | Original post link

For software load balancing, haproxy+keepalived is commonly used. I’ve also used others.

I previously wrote an article on this topic: 专栏 - 这么多TiDB负载均衡方案总有一款适合你 | TiDB 社区

If conditions allow, go for F5; it’s more effortless and worry-free.

| username: 我是咖啡哥 | Original post link

F5 network engineers are not in the same department, can’t be bothered to deal with it together. :joy:

| username: 我是咖啡哥 | Original post link

This article is quite clear, I’ll try replacing LVS with HAProxy. :grinning:

| username: redgame | Original post link

HAProxy

| username: 春风十里 | Original post link

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.

| username: linnana | Original post link

Strongly support TiDB official development of a component.

| username: chenhanneu | Original post link

It seems like there is a tiproxy in the roadmap?

| username: TiDBer_IU34EeRL | Original post link

The CLB on Alibaba Cloud

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.