Sysbench is a scriptable, multi-threaded benchmark tool based on LuaJIT. While Sysbench can help you create arbitrarily complex workloads that don’t involve a database server, it’s most commonly used to perform database benchmarks. You can use Sysbench to evaluate any MySQL database to determine the associated reads, writes, queries/second (QPS), transactions/second (TPS), and latency. Using Sysbench to monitor MySQL performance is especially important when running a database under an intensive load.
In this post, I’ll describe how to use Sysbench to benchmark a database in Azure Database for MySQL – Flexible Server.
To download and install Sysbench on a Linux machine, run the following commands:
sudo apt-get update
sudo apt-get install sysbench
Important: It is recommended to size your Linux machine to ensure that is has the same number of CPUs as does you Azure Database for MySQL flexible server.
Note: To avoid capturing network latencies associated with traffic travelling across data centers, be sure to install Sysbench on a Linux machine located in the same datacenter and availability zone as your Azure Database for MySQL flexible server.
After you install Sysbench, you’ll need to create a test database in your Azure Database for MySQL flexible server. For the purposes of this post, we’ll use a test database names testdb.
To create a test database, perform the following steps.
mysql -h servername.mysql.database.azure.com -u username -p
create database testdb
cd /usr/share/sysbench
date ; sysbench oltp_write_only.lua --tables=10 --table-size=1000000 --threads=10 --thread-init-timeout=120 --time=720000 --mysql-host= servername.mysql.database.azure.com --mysql-db=testdb --mysql-user= username --mysql-password='password' --mysql-port=3306 --report-interval=10 --percentile=95 --mysql-ssl=required prepare ; date
This command will use ten threads to create ten tables, each containing one million records, and will then create indexes for all the tables.
Note: Ensuring that the number of threads equals the NUM_OF_TABLES in the import Sysbench command line will significantly reduce the time required for the import process.
After you’ve created the tables and indexes, you need to run the workload so you can benchmark the database server. While Sysbench offers many OLTP workload options, the most commonly used workloads are the:
Regardless of the type of workload you test for, it’s important to consider a couple of specific server parameters.
show engine innodb status\G
ulimit -n 620
Based on the type of workload you are running and want to benchmark, use the appropriate command below.
sysbench oltp_read_write.lua --tables=10 --table-size=1000000 --db-driver=mysql --threads=310 --time=360 --mysql-host=servername.mysql.database.azure.com --mysql-db=testdb --mysql-user=username --mysql-password='password' --mysql-port=3306 --report-interval=1 --percentile=95 --mysql-ssl=required run | tee ~/test_read_write.log
sysbench oltp_read_only.lua --tables=10 --table-size=1000000 --db-driver=mysql --threads=310 --time=360 --mysql-host=servername.mysql.database.azure.com --mysql-db=testdb --mysql-user=username --mysql-password='password' --mysql-port=3306 --report-interval=1 --percentile=95 --mysql-ssl=required run | tee ~/test_readOnly.log
sysbench oltp_write_only.lua --tables=10 --table-size=1000000 --db-driver=mysql --threads=310 --time=360 --mysql-host=servername.mysql.database.azure.com --mysql-db=testdb --mysql-user=username --mysql-password='password' --mysql-port=3306 --report-interval=1 --percentile=95 --mysql-ssl=required run | tee ~/test_writeOnly.log
After the test completes, you’ll find the results stored in an associated log file. For example, the results of running the read_write benchmark test are stored in a file named test_read_write.log.
Note: It's critical to size your Azure Database for MySQL flexible server adequately to run the Sysbench test, as holding the Sysbench dataset in the buffer pool is a best practice to reduce latency. To estimate memory consumption, use the following:
Memory consumption estimation: 10 tables x 10000000 table size will consume 20GB of the innodb buffer pool.
The Sysbench results for a benchmark test that ran for 600 seconds with ~86K per second QPS and an average latency of 236.75 ms is shown in the following graphic:
You now have the information necessary to Sysbench to evaluate your MySQL databases to determine the associated reads, writes, QPS, TPS, and latency. Be sure to leverage this valuable detail to monitor MySQL parameters when running a database under an intensive load.
If you have any feedback or questions, please leave a comment below or email our team at AskAzureDBforMySQL@service.microsoft.com. Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.