A detailed tutorial on using sysbench to test MySQL performance, sysbenchmysql

Source: Internet
Author: User

A detailed tutorial on using sysbench to test MySQL performance, sysbenchmysql

Sysbench is a modular, cross-platform, multi-thread benchmark testing tool used to evaluate the database load of different system parameters.
Currently sysbench code hosted on launchpad, Project address: https://launchpad.net/sysbench (the original official http://sysbench.sourceforge.net has been unavailable), the source code uses bazaar management.

1. Download the source code package
Install the epel package to install the bzr client:

rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Then you can start to install the bzr client:

yum install bzr

Then you can use the bzr client to download the tpcc-mysql source code.

cd /tmpbzr branch lp:sysbench

MySQL Chinese network is convenient:

Http://imysql.com/wp-content/uploads/2014/09/sysbench-0.4.12-1.1.tgz

Sysbench supports the following test modes:

1. CPU Performance
2. Disk I/O performance
3. scheduler Performance
4. Memory Allocation and transmission speed
5. POSIX thread Performance
6. database performance (OLTP benchmark test)
Currently, sysbench mainly supports mysql, drizzle, pgsql, oracle, and other databases.

Ii. Compilation and Installation
The compilation process is very simple. For details, refer to the README document. The simple steps are as follows:

cd /tmp/sysbench-0.4.12-1.1./autogen.sh./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib && make
# If make does not report an error, the binary command line tool sysbenchls-l sysbench-rwxr-xr-x 1 root 3293186 Sep 21 sysbench will be generated in the sysbench directory.

3. Prepare for OLTP Test
Initialize the test database environment (a total of 10 test tables, with 100000 records in each table, filling in randomly generated data ):

cd /tmp/sysbench-0.4.12-1.1/sysbenchmysqladmin create sbtest./sysbench --mysql-host=1.2.3.4 --mysql-port=3317 --mysql-user=tpcc --mysql-password=tpcc \ --test=tests/db/oltp.lua --oltp_tables_count=10 --oltp-table-size=100000 --rand-init=on prepare

Explanations of these parameters:

-- Test = tests/db/oltp. lua indicates that the tests/db/oltp. lua script is called to test the oltp mode.
-- Oltp_tables_count = 10 indicates that 10 test tables will be generated.
-- Oltp-table-size = 100000 indicates that the amount of data filled in each test table is 100000
-- Rand-init = on indicates that each test table is filled with random data.

If it is on the local machine, you can also use-mysql-socket to specify the socket file to connect. The duration of loading test data depends on the amount of data. If the process is long, you need to wait patiently.

In a real test scenario, it is recommended that there be no less than 10 data tables and no less than 5 million rows of data in a single table, depending on the server hardware configuration. If you are equipped with a high IOPS device such as SSD or pcie ssd, we recommend that you have at least 0.1 billion rows of data in a single table.

4. Perform OLTP Testing

On the basis of the above initialization data parameters, add some parameters to start the test:

./sysbench --mysql-host=1.2.3.4. --mysql-port=3306 --mysql-user=tpcc \--mysql-password=tpcc --test=tests/db/oltp.lua --oltp_tables_count=10 \--oltp-table-size=10000000 --num-threads=8 --oltp-read-only=off \--report-interval=10 --rand-type=uniform --max-time=3600 \ --max-requests=0 --percentile=99 run >> ./log/sysbench_oltpX_8_20140921.log

Several options are explained a little.

-- Num-threads = 8 indicates that eight concurrent connections are initiated.
-- Oltp-read-only = off indicates that the read-only test is not performed, that is, the read/write mixed mode test is used.
-- Report-interval = 10 indicates that a Test Progress report is output every 10 seconds.
-- Rand-type = uniform indicates that the random type is fixed mode. The other several optional random modes are uniform (fixed), gaussian (gaussian), special (specific), and pareto ()
-- Max-time = 120 indicates the maximum execution duration is 120 seconds.
-- Max-requests = 0 indicates that the total number of requests is 0. Because the total execution duration has been defined above, the total number of requests can be set to 0. You can also set only the total number of requests, do not set the maximum execution duration
-- Percentile = 99 indicates that the sampling ratio is set. The default value is 95%, that is, to discard a 1% long request, and take the maximum value in the remaining 99%.

That is, the concurrent OLTP test is simulated for 10 tables. Each table has 10 million rows of records and the stress test duration is 1 hour.

In a real test scenario, it is recommended that the duration of the stress test be no less than 30 minutes. Otherwise, the test data may not be of reference significance.

5. Test Result explanation:

The test results are described as follows:

Copy codeRun the following code: sysbench 0.5: multi-threaded system evaluation benchmark.

Running the test with following options:
Number of threads: 8
Report intermediate results every 10 second (s)
Random number generator seed is 0 and will be ignored


Threads started!
-- Test results are reported every 10 seconds. tps, read per second, write per second, response time of more than 99%
[10 s] threads: 8, tps: 1111.51, reads/s: 15568.42, writes/s: 4446.13, response time: 9.95 ms (99%)
[20 s] threads: 8, tps: 1121.90, reads/s: 15709.62, writes/s: 4487.80, response time: 9.78 ms (99%)
[30 s] threads: 8, tps: 1120.00, reads/s: 15679.10, writes/s: 4480.20, response time: 9.84 ms (99%)
[40 s] threads: 8, tps: 1114.20, reads/s: 15599.39, writes/s: 4456.30, response time: 9.90 ms (99%)
[50 s] threads: 8, tps: 1114.00, reads/s: 15593.60, writes/s: 4456.70, response time: 9.84 ms (99%)
[60 s] threads: 8, tps: 1119.30, reads/s: 15671.60, writes/s: 4476.50, response time: 9.99 ms (99%)
OLTP test statistics:
Queries saved med:
Read: 938224 -- total number of reads
Write: 268064 -- total number of writes
Other: 134032 -- total number of other operations (operations other than SELECT, INSERT, UPDATE, and DELETE, such as COMMIT)
Total: 1340320 -- total number of all
Transactions: 67016 (1116.83 per sec.) -- total number of transactions (transactions per second)
Deadlocks: 0 (0.00 per sec.) -- total number of deadlocks
Read/write requests: 1206288 (20103.01 per sec.) -- total read/write count (read/write times per second)
Other operations: 134032 (2233.67 per sec.) -- total number of other operations (other operations per second)

General statistics: -- some statistical results
Total time: 60.0053 s -- total time consumed
Total number of events: 67016 -- total number of transactions
Total time taken by event execution: 479.8171 s -- sum of time consumed by all transactions (parallel factors not considered)
Response time: -- response time Statistics
Min: 4.27 ms-Minimum Time consumed
Avg: 7.16 ms-Average time consumption
Max: 13.80 ms -- maximum time consumed
Approx. 99 percentile: 9.88 ms-over 99% average time consumption

Threads fairness:
Events (avg/stddev): 8377.0000/44.33
Execution time (avg/stddev): 59.9771/0.00

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.