Benchmarking MySQL with JMeter

Wiki

Apache JMeter may be used to test performance both on static and dynamic resources (Files, Web dynamic languages - PHP, Java, ASP.NET, etc. -, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types. You can use it to make a graphical analysis of performance or to test your server/script/object behavior under heavy concurrent load.

Official Website jmeter.apache.org

Download Last Releases

MySQL Connectors JDBC Driver for MySQL (Connector/J) www.mysql.com/products/connector

Environment

Operating System        : OS X 10.9.2 Mavericks
Apache JMeter Version   : 2.11
MySQL Version           : 5.7.3
JDBC Driver for MySQL   : mysql-connector-java-5.1.30
Java Version            : 1.8.0_20-ea
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b05)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b05, mixed mode)

Install Apache JMeter

Download and unzip apache-jmeter-2.11_src.zip.

Install the JDBC Driver for MySQL

In order for JMeter to access a MySQL database as a client, it needs a JDBC database driver. For MySQL this is called MySQL Connector/J and is available at http://www.mysql.com/products/connector/j/. Download Connector/J and unzip the file. This will produce a directory containing the Connector/J files. In this directory you will find the connector jar file (mysql-connector-java-version-ga-bin.jar). Copy this file to the JMeter lib directory.

Open apache-jmeter-2.11/bin/ApacheJMeter.jar, File → Templates... → Select Template [JDBC Load Test] → Create.

Configure the JDBC Sampler

Start JMeter and under the test plan node create a Thread Group, and under that create a JDBC Request Sampler.
For MySQL the Driver Class should be com.mysql.jdbc.Driver.

The JDBC URL is of this form: jdbc:mysql://server/databaseName?user=username&password=password

The SQL Query String is the SQL Query you want to benchmark. Start with something simple: create a table in the test database and execute a desc query against it.

Benchmarking MySQL with JMeter

Add JDBC Request

Open Thread Group → JDBC Request → SQL Query

select * from rl_user where username like '%xuri%'

Benchmarking MySQL with JMeter

Add Assertion

Right-click on the Thread Group → Assertions → Response Assertion → Apply to [Main sample and sub-samples] → Patterns to Test [Add]

xuri

Benchmarking MySQL with JMeter

Add Listener

Right-click on the Thread Group → Listener → Graph Results
Right-click on the Thread Group → Listener → Summary Report
Set the Number of Threads(users), Ramp-Up Perios(in seconds) and Loop Count in Thread Group.

Benchmark

Click on the menu bar Run → Start
Here are the results

Benchmarking MySQL with JMeter

Benchmarking MySQL with JMeter

0.00 avg. rating (0% score) - 0 votes