Does the TiDB server need load balancing?

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

Original topic: TiDB server需要做负载均衡么

| username: WinterLiu

As a newbie, may I ask if in actual production, do you all perform load balancing for multiple TiDB servers before providing services externally?

| username: TiDBer_QYr0vohO | Original post link

Yes, you need to use a load balancer in front of the tidb-server, such as HAProxy, Nginx, or a cloud provider’s LB.

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

It needs to be done, otherwise there will be no high availability and the computation will not be balanced.

| username: WinterLiu | Original post link

Okay, thank you!

| username: 像风一样的男子 | Original post link

There is a column written by an expert that you can check out: 专栏 - 搭建TiDB负载均衡环境-HAproxy+KeepAlived实践 | TiDB 社区

| username: zhanggame1 | Original post link

You need to do it, if you have money, go for F5.

| username: hey-hoho | Original post link

I guess you need this:

| username: 春风十里 | Original post link

It is recommended that the official provide a load balancing solution.

| username: Jellybean | Original post link

Yes, the TiDB server is a stateless node. To ensure high availability, it needs to be used in conjunction with load balancing tools. There are many such tools, such as HAproxy, Nginx, etc.

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

For paid options, you can use F5, or ELB on the cloud. For free options, you can use HAproxy or LVS. For setting up a high availability environment, refer to the two articles I wrote:

Setting up TiDB Load Balancing Environment - HAproxy + KeepAlived Practice - My Column - 专栏 - 搭建TiDB负载均衡环境-HAproxy+KeepAlived实践 | TiDB 社区

Setting up TiDB Load Balancing Environment - LVS + KeepAlived Practice - My Column - 专栏 - 搭建TiDB负载均衡环境-LVS+KeepAlived实践 | TiDB 社区

| username: zhanggame1 | Original post link

There is also

| username: redgame | Original post link

It is common to use multiple TiDB Server instances for load balancing and to provide services externally. The purpose of this is to improve system performance, fault tolerance, and scalability.

| username: TiDB_C罗 | Original post link

You can use HAProxy in front of TiDB, but how do you ensure the high availability of HAProxy?

| username: 像风一样的男子 | Original post link

Adding keepalive will make it highly available.

| username: TiDB_C罗 | Original post link

Keepalived still requires a VIP. My idea is to use domain name resolution, using Consul to add three HAProxy instances and resolve them to one domain name. I wonder if anyone has deployed it this way before.

| username: 像风一样的男子 | Original post link

Generally, large websites use DNS domain name resolution as the first level of load balancing, but I haven’t tried using it for backend services. One drawback of this approach is that there may be cached resolution records at every stage. If the server IP changes, even if the A record is modified, it will only take effect after the caches at all levels expire.

| username: 春风十里 | Original post link

This is a solution for open-source products. What I mean is that customers do not need to configure any other components themselves. For example, Oracle RAC provides SCAN VIP which is automatically deployed and can provide load balancing functionality by default.

| username: zhanggame1 | Original post link

Domestic distributed databases probably don’t have this feature. For example, OceanBase also needs to use load balancing equipment.

| username: system | Original post link

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