Database Performance Testing With Apache JMeter
Learn how to construct your database performance testing plan with all the most important elements, including a thread group, JDBC request, and summary report.
Join the DZone community and get the full member experience.
Join For FreeDatabase 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
- Install Java Development Kit.
- Install Apache JMeter.
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:
- Variable Name: myDatabase
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.
To view the test results, perform the following:
- In the left pane, right-click Thread Group.
- Select Add > Listener > View Results Tree/Summary Report/Graph Results.
- Save the test plan and click Run (Start or Ctrl + R) to run the test.
All the test results will be stored in the Listener.
Viewing Test Results
We can look at tree view, table view, graph view, and response time graph view.
Tree View
The results can be viewed in tree format, as shown in the below diagram:
Table View
The results can be viewed in table format, as shown in the below diagram:
Graph View
The results can be viewed in graph format, as shown in the below diagram:
Response Time Graph View
The results can be viewed in graph format, as shown in the below diagram:
And that's it!
Published at DZone with permission of Rathnadevi Manivannan. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments