TiProxy Performance Test Report

This report tests the performance of TiProxy in the OLTP scenario of Sysbench and compares it with HAProxy.

The results are as follows:

  • The QPS upper limit of TiProxy is affected by the type of workload. Under the basic workloads of Sysbench and the same CPU usage, the QPS of TiProxy is about 20% to 40% lower than that of HAProxy.
  • The number of TiDB server instances that TiProxy can hold varies according to the type of workload. Under the basic workloads of Sysbench, a TiProxy can hold 4 to 10 TiDB server instances of the same model.
  • The performance of TiProxy is more affected by the number of vCPUs, compared to HAProxy. When the returned data is 10,000 rows and the CPU usage is the same, the QPS of TiProxy is about 30% lower than that of HAProxy.
  • The performance of TiProxy increases almost linearly with the number of vCPUs. Therefore, increasing the number of vCPUs can effectively improve the QPS upper limit.

Test environment

Hardware configuration

ServiceMachine TypeCPU ArchitectureInstance Count
TiProxy4C8GAMD641
HAProxy4C8GAMD641
PD4C8GAMD643
TiDB8C16GAMD648
TiKV8C16GAMD648
Sysbench8C16GAMD641

Software

ServiceSoftware version
TiProxyv0.2.0
HAProxy2.9.0
PDv7.6.0
TiDBv7.6.0
TiKVv7.6.0
Sysbench1.0.17

Configuration

TiProxy configuration

In the test, TLS is not enabled between the client and TiProxy, or between TiProxy and TiDB server.

proxy.conn-buffer-size: 131072

HAProxy configuration - haproxy.cfg file

global # Global configuration. log 127.0.0.1 local2 # Specifies the global syslog server. You can define up to two. pidfile /var/run/haproxy.pid # Write the PID of the HAProxy process to pidfile. maxconn 4096 # The maximum number of concurrent connections that a single HAProxy process can accept, equivalent to the command line parameter "-n". nbthread 4 # The maximum number of threads. The upper limit of the number of threads is the same as the number of CPUs. user haproxy # Same as UID parameter. group haproxy # Same as GID parameter. A dedicated user group is recommended. daemon # Run HAProxy as a daemon in the background, which is equivalent to the command line parameter "-D". You can also disable it with the "-db" parameter on the command line. stats socket /var/lib/haproxy/stats # The location where the statistics are saved. defaults # Default configuration. log global # Inherit the settings of the global configuration section. retries 2 # The maximum number of times to try to connect to the upstream server. If the number of retries exceeds this value, the backend server is considered unavailable. timeout connect 2s # The timeout period for HAProxy to connect to the backend server. If the server is located on the same LAN as HAProxy, set it to a shorter time. timeout client 30000s # The timeout period for the client to be inactive after the data transmission is completed. timeout server 30000s # The timeout period for the server to be inactive. listen tidb-cluster # Configure database load balancing. bind 0.0.0.0:3390 # Floating IP address and listening port. mode tcp # HAProxy uses layer 4, the transport layer. balance leastconn # The server with the least number of connections receives the connection first. `leastconn` is recommended for long session services, such as LDAP, SQL, and TSE, rather than short session protocols, such as HTTP. This algorithm is dynamic, and the server weight is adjusted during operation for slow-start servers. server tidb-1 10.9.18.229:4000 check inter 2000 rise 2 fall 3 # Detects port 4000 at a frequency of once every 2000 milliseconds. If it is detected as successful twice, the server is considered available; if it is detected as failed three times, the server is considered unavailable. server tidb-2 10.9.39.208:4000 check inter 2000 rise 2 fall 3 server tidb-3 10.9.64.166:4000 check inter 2000 rise 2 fall 3

Basic workload test

Test plan

This test aims to compare the QPS of TiProxy and HAProxy under four types of workloads: point select, read only, write only, and read write. Each type of workload is tested with different concurrency to compare the QPS of TiProxy and HAProxy.

The following command is used to perform the test:

sysbench $testname \ --threads=$threads \ --time=1200 \ --report-interval=10 \ --rand-type=uniform \ --db-driver=mysql \ --mysql-db=sbtest \ --mysql-host=$host \ --mysql-port=$port \ run --tables=32 --table-size=1000000

Point Select

TiProxy test results:

ThreadsQPSAvg latency(ms)P95 latency (ms)TiProxy CPU usageTiDB overall CPU Usage
20439350.450.63210%900%
50878700.570.77350%1700%
100916111.091.79400%1800%

HAProxy test results:

ThreadsQPSAvg latency(ms)P95 latency (ms)HAProxy CPU usageTiDB overall CPU Usage
20436290.460.63130%900%
501029340.490.61320%2000%
1001578800.630.81400%3000%

Read Only

TiProxy test results:

ThreadsQPSAvg latency(ms)P95 latency (ms)TiProxy CPU usageTiDB overall CPU Usage
507181611.1412.98340%2500%
1007929920.1723.95400%2800%
2008337138.3746.63400%2900%

HAProxy test results:

ThreadsQPSAvg latency(ms)P95 latency (ms)HAProxy CPU usageTiDB overall CPU Usage
507494510.6712.08250%2500%
10011852613.4918.28350%4000%
20013110224.3934.33390%4300%

Write Only

TiProxy test results:

ThreadsQPSAvg latency(ms)P95 latency (ms)TiProxy CPU usageTiDB overall CPU Usage
100677628.8515.27310%3200%
3008111322.1838.25390%3900%
5007926037.8356.84400%3800%

HAProxy test results:

ThreadsQPSAvg latency(ms)P95 latency (ms)HAProxy CPU usageTiDB overall CPU Usage
100745018.0512.30220%3500%
3009794218.3631.94280%4300%
50010535228.4449.21300%4500%

Read Write

TiProxy test results:

ThreadsQPSAvg latency(ms)P95 latency (ms)TiProxy CPU usageTiDB overall CPU Usage
506017016.6218.95280%2700%
1008169124.4831.37340%3600%
2008875545.0554.83400%4000%

HAProxy test results:

ThreadsQPSAvg latency(ms)P95 latency (ms)HAProxy CPU usageTiDB overall CPU Usage
505815117.1920.37240%2600%
1009412321.2426.68370%4100%
20010742337.2145.79400%4700%

Result set test

Test plan

This test aims to compare the performance of TiProxy and HAProxy under different result set row numbers. This test uses 100 concurrency, and compares the QPS of TiProxy and HAProxy with result set row numbers of 10, 100, 1000, and 10000.

The following command is used to perform the test:

sysbench oltp_read_only \ --threads=100 \ --time=1200 \ --report-interval=10 \ --rand-type=uniform \ --db-driver=mysql \ --mysql-db=sbtest \ --mysql-host=$host \ --mysql-port=$port \ --skip_trx=true \ --point_selects=0 \ --sum_ranges=0 \ --order_ranges=0 \ --distinct_ranges=0 \ --simple_ranges=1 \ --range_size=$range_size run --tables=32 --table-size=1000000

Test results

TiProxy test results:

Range SizeQPSAvg latency(ms)P95 latency (ms)TiProxy CPU usageTiDB overall CPU UsageInbound Network (MiB/s)Outbound Network (MiB/s)
10921001.091.34330%3700%150150
100579311.732.30370%2800%840840
1000824912.1218.95250%1300%11401140
10000826120.77363.18230%600%11401140

HAProxy test results:

Range SizeQPSAvg latency(ms)P95 latency (ms)HAProxy CPU usageTiDB overall CPU UsageInbound Network (MiB/s)Outbound Network (MiB/s)
10932021.071.30330%3800%145145
100643481.551.86350%3100%830830
1000894411.1814.73240%1400%11001100
10000908109.96139.85180%600%11301130

Scalability test

Test plan

This test aims to verify that the performance of TiProxy is proportional to its specifications, to ensure that upgrading the specifications of TiProxy can improve its QPS upper limit. This test uses TiProxy instances with different vCPU numbers and concurrency to compare the QPS.

The following command is used to perform the test:

sysbench oltp_point_select \ --threads=$threads \ --time=1200 \ --report-interval=10 \ --rand-type=uniform \ --db-driver=mysql \ --mysql-db=sbtest \ --mysql-host=$host \ --mysql-port=$port \ run --tables=32 --table-size=1000000

Test results

vCPUThreadsQPSAvg latency(ms)P95 latency (ms)TiProxy CPU usageTiDB overall CPU Usage
240585080.680.97190%1200%
4801048900.761.16390%2000%
61201555200.771.14590%2900%
81602021340.791.18800%3900%