Database performance testing is used to identify performance issues before deploying database applications for end users. Database load testing is used to test the database applications for performance, reliability, and scalability using varying user load. Load testing involves simulating real-life user load for the target database applications and is used to determine the behavior of the database applications when multiple users hit the applications simultaneously.

Prerequisites

Use Case

Let's perform database load testing to measure the performance of a database using Apache JMeter by configuring MySQL JDBC driver.

Building Database Test Plan

A test plan describes a series of steps to be executed by JMeter on running a database test. To construct a test plan, the following elements are needed:

Thread group.

JDBC request.

Summary report.

Adding Users

The first step involved in creating a JMeter test plan is to add a thread group element. The element provides details about the number of users to be simulated, the frequency of requests to be sent by the users, and the number of requests to be sent by the users.

To add a thread group element, perform the following:

In the left pane, right-click Test Plan.

Select Add > Threads (Users) > Thread Group.

Provide the thread group name as JDBC Users.

Click Add to modify the default properties as:

No. of Threads (users): 10.

Ramp-Up Period (in seconds): 100.

Loop Count: 10, as shown in the below diagram:

Note: The ramp-up period states the time taken to "ramp-up" to the full number of threads chosen. As 10 threads are used in our use case and the ramp-up period is 100 seconds, JMeter will take 100 seconds to get all 10 threads up and running. Each thread will start 10 (100/10) seconds after the previous thread was begun. The query will be executed for 10 (threads)*10 (loop) = 100 times. Likewise, for 10 tables, the total number of samples is 100.

Adding JDBC Requests

To add a JDBC request, perform the following:

In the left pane, right-click Thread Group.

Select Add > Config Element > JDBC Connection Configuration.

Configure the following details:

Variable Name: myDatabase

Note: This name needs to be unique, as it is used by the JDBC Sampler to identify the configuration to be used.

Database URL: jdbc:mysql://ipOfTheServer:3306/cloud

JDBC Driver class: com.mysql.jdbc.Driver

Username: Username of the database.

Password: Password for the database username, as shown in the below diagram:

Adding Sampler

To add a sampler, perform the following:

In the left pane, right-click Thread Group.

Select Add > Sampler > JDBC Request.

Provide the following details:

Variable Name: myDatabase (same as in the configuration element).

Enter the SQL Query string field as shown in the below diagram:

Adding Listener to View/Store Test Results

A listener is used to store test results of all JDBC requests in a file and present the results.