How to Implement Load Balancing in TiDB

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

Original topic: tidb负载均衡如何实现

| username: liujq132

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version] 6.1.1
[Reproduction Path] How to achieve TiDB load balancing
[Encountered Problem: Problem Phenomenon and Impact] How to achieve TiDB load balancing
[Resource Configuration] Can OpenResty achieve load balancing?
[Attachment: Screenshot / Log / Monitoring]

| username: srstack | Original post link

You can use LB components like haproxy, or you can use the official LB TiProxy. Of course, using openresty for reverse proxy is also okay.

| username: zhanggame1 | Original post link

For software, use HAProxy; for hardware, use F5 and other load balancers.

| username: tidb菜鸟一只 | Original post link

nginx can indeed proxy like this.

| username: 孤君888 | Original post link

Our approach is to add a layer of Haproxy reverse proxy in front of TIDB Serve. The application just needs to connect to Haproxy. You can refer to this.

| username: 裤衩儿飞上天 | Original post link

Has TiProxy been officially released?

| username: srstack | Original post link

Not yet, but TiDB Cloud is available as a feature for external services.

| username: liujq132 | Original post link

Currently using HAProxy + Keepalived is quite effective.

| username: breakyang | Original post link

I am also looking into this load balancing. I am not sure if the tidb-loadbalance client load balancing can be used in a production environment.

| username: Jellybean | Original post link

TiDB itself currently does not have a general tidb-server load balancing component. The official recommendation is to use third-party components for load balancing. Options include nginx or haproxy+keepalived or other LB tools, as long as they can distribute client traffic evenly to different tidb server nodes.

| username: YuchongXU | Original post link

You can consider implementing it in hardware or software. The front-end application manually configures different nodes.

| username: system | Original post link

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