Let's learn&succeed together with Soft Industry's blog. Read, Share, get Inspired, Gain!


Company news

JMeter: databases load testing Part I

July 23, 2013

database load testing

We present series of articles form QA specialists of Soft Industry Software Testing department “JMeter: databases load testing”. Find out what is JMeter, how to configure it and why should it be used when performing a database stress testing.

Apache JMeteris a powerful tool to run a load testing both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more). It allows to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types. It provides an option of making a graphical analysis of performance or testing your server/script/object behavior under heavy concurrent load.

So, how to use JMeter during databases load testing? First of all we’ll need:

  1. JMeter application.
  2. A database. JMeter supports all types of databases. Only jdbc driver will be changed in settings.
  3. Driver that will be used for connection with the database.

Driver for psql you can downland following this link http://jdbc.postgresql.org/download.htm and the one for mysql is available here http://www.mysql.com/products/connector/ . For mysql driver: un-zip downloaded file and place it directory into the JMeter /lib.

For a database load testing it is necessary to configure JMeter. It includes two elements, that provide connection to the database. In today’s article we will highlight the JDBC Connection Configuration element.

Follow the steps to configure it:
Test Plan → Add → Thread Group
Thread Group → Add → Config Element → JDBC Connection Configuration:
jmeter settings
For psql the configuration is following:
jmeter configure
JDBC Connection Configuration is used to create and manage connection pools.
Identify connection pools in Variable Name field. It is necessary to separate them, if we are testing a few databases simultaneously or emulate different load types on one and the same database.

Next we proceed to the pool settings. It has two operating modes: sharing mode and single connection per thread. For sharing mode, enter positive number in the Max Number of Connections field. For single connection per thread – number, is equal to zero.

Peculiar features of each mode:
sharing mode. There is a set of open connections in the pool and before running a query, a thread has to receive spare connection and only then contact a database. Most of java application based on this principle. Thus, to emulate application work, it is better to choose this mode.
single connection per thread. In order to connect to the database, a separate socket will be created for every thread in the thread group. As a result, the number of jdbs-sessions will be equal to the number of threads. This mode is better to use when you want to receive the optimal number of sessions for the given type of query. While running the test, we can change the number of threads in accordance with thread groups rules. For testing engineer it means that he can manage the number of the parallel sessions indirectly.

Pool Timeout – time interval for establishing the connection to the database. If it failed to connect the database, an error will be returned to the poll, running jdbc-query. This option is necessary, if you choose to work in sharing mode.

Idle Cleanup Interval is a period of time upon which, all inactive sessions will be closed.

Auto Commit and Transaction Isolation settings are usually configured at the database side. Here you can only redefine them.

In the next article we will speak about how to configure Connection Validation by Pool and Database Connection Configuration section as well as provide information about JMeter JDBC Request.
More on the way. Sign up for the newsletters and you won’t miss the next article!