Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Database Performance Testing With Apache JMeter

DZone's Guide to

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.

· Database Zone ·
Free Resource

Running out of memory? Learn how Redis Enterprise enables large dataset analysis with the highest throughput and lowest latency while reducing costs over 75%! 

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:

thread_propertiesNote: 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:

jdbc_connection_configuration

Adding Sampler

To add a sampler, perform the following:

  • In the left pane, right-click Thread Group.
  • Select AddSamplerJDBC 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:

jdbc_request

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 ListenerView 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:view_results_tree

Table View

The results can be viewed in table format, as shown in the below diagram:table_view

Graph View

The results can be viewed in graph format, as shown in the below diagram:graph_view

Response Time Graph View

The results can be viewed in graph format, as shown in the below diagram:response_time_graph_view

And that's it! 

Running out of memory? Never run out of memory with Redis Enterprise databaseStart your free trial today.

Topics:
database performance ,performance testing ,database ,apache jmeter ,jdbc ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}