Performance Comparison
Using a database proxy, one of the key objectives is to distribute the request load on the database to the replica, thus maintaining the stability of the database. Utilizing the Read-Write separation capability of a database proxy can significantly enhance the request processing capacity of the entire database cluster, enabling faster responses to business functions.
Test Parameters
For this load test, we used the industry-standard multi-threaded performance testing tool sysbench with the following parameters:
- sysbench version: sysbench 1.0.20
- sysbench test machine: Identical Surfercloud O-type cloud host in the same region with 8 cores and 8GB of RAM
- Operating System: CentOS 8.3
- Test Dataset: 10 tables, each table containing 10 million rows
- Proxy Node Service Configuration: 8 cores and 16GB of RAM
The test commands used were:
sysbench --test=/usr/share/sysbench/oltp_read_only.lua --db-driver=mysql --mysql-host=$ip --mysql-port=3306 --mysql-user=xxxx --mysql-password=xxxxx --mysql-db=sysbenchtest --report-interval=5 --max-requests=0 --max-time=300 --num-threads=$thread_num run
Curve of Read Requests with Varying Load Pressure
As shown in the figure above, we conducted performance testing on a 6-core 8GB UDB MySQL instance with one master and two replicas using two proxy nodes under varying levels of database request pressure. It is evident that when the database request pressure increases, using a database proxy demonstrates excellent stability. In contrast, direct connections to the master database show a performance decrease with increasing pressure. Additionally, we observed the CPU pressure on the master and replica databases under different scenarios, resulting in the following curves:
From the graph, it is evident that request pressure is distributed to the replicas, thereby reducing the load on the master database and improving performance.
Comparison of Database Performance with Different Proxy Configurations
The above figure illustrates the performance differences between different database configurations using a database proxy, with the same number of proxy nodes and databases. It is evident that when the request pressure is high enough, accessing the databases through a database proxy can better leverage the service performance of the database cluster.