Performing a Database Load Test on MySQL using Apache JMeter

In this article I’d like to share how to perform load test on MySQL Server using Apache JMeter.

Pre-requisites:

  1. MySQL

To get the driver, navigate to MySQL Community Downloads page > Select Platform Independent from the Operating System dropdown, download and export the mysql-connector-java-X.X.X.zip file to get the .jar file.

In this example I’ll test a sample table called reviews under database called amazon:

Here’s how we can start preparing the Load Test Plan in JMeter:

  1. After creating a new Test Plan, click Browse and select the downloaded MySQL Connector Java .jar file as follows:

2. Add JDBC Connection Configuration to your Test Plan through right click on the Test Plan which in this example I used is “DB Plan” and then select to Add > Config Element > JDBC Connection Configuration. Within JDBC Connection Configuration, specify the following fields

  • Variable Name for created pool to uniquely identify the configuration. It is used by the JDBC Sampler to identify the configuration to be used. In this example variable name is myDb.

And also the following fields:

  • Database URL: jdbc:mysql://ipOfTheServer:3306/databasename
(e.g. jdbc:mysql://localhost:3306/amazon)
  • JDBC Driver class: com.mysql.jdbc.Driver

3. Add Thread Group into your Test Plan by selecting Add > Thread (Users) > Thread Groups. Thread Group will allow you to set:

  • number of users (Thread) you want to simulate

4. Add a JDBC Request by selecting Add > Sampler > JDBC Request and specify the following details:

  • Request Name.

5. Add a Listener (e.g. View Result Tree & Summary Report) by selecting Add > Listener > Summary Report to store all of the results of your JDBC requests in a file and presenting the results.

Once you run the Test Plan, the test results will show up in the Listener (‘o’)9

A curious potato exploring new things on software quality