Load Testing InfluxDB Using JMeter
Learn about the basics of creating a load testing plan for an InfluxDB instance using Apache JMeter in this step-by-step walkthrough.
Join the DZone community and get the full member experience.Join For Free
InfluxDB is a Time Series Database built to handle high write & query loads. It is a custom high-performance datastore written specifically for timestamped data, including DevOps monitoring, application metrics, IoT sensor data, and real-time analytics.
This article talks about the basics of load testing an InfluxDB instance using Apache JMeter.
JMeter doesn't come with a specific template for InfluxDB, but it is straightforward to create one from scratch.
The releases of JMeter I am referring to is the 3.2. The steps below have been tested against InfluxDB databases release 1.3.
Creating the Test Plan
InfluxDB exposes HTTP APIs for querying and modifying data. So a JMeter test plan for it is quite similar to a REST API test plan.
Start the JMeter GUI and create a new empty test plan. Right-click on the project root and then add an HTTP Header Manager (Add -> Config Element -> HTTP Header Manager). There you can configure the values for the HTTP request header fields. The minimum required is to set the Content-Type to text/plain.
Setting Up the Thread Group
Right-click on the test plan root and add a Thread Group (Add -> Threads (Users) -> Thread Group). Setup the number of threads, their ramp-up period and loop count. Then right-click on it and add an HTTP Request Defaults component (Add -> Config Element -> HTTP Request Defaults) and at least one HTTP Request (Add -> Sampler -> HTTP Request). In the Basic tab of the HTTP Request Defaults, you can set up all of those default values common to any HTTP Request for this thread group (like the protocol, the hostname or IP address, the port number and the path).
On each HTTP request, you just set up the method type and all of the parameters to send along with the request. In order to load test an InfluxDB database when querying data, you need to pass a parameter called q which value is the query to execute (see an example in the figure below).
Setting the Result Views and Aggregators
In order to check the status and the results of a load test, you need to add some listeners to the thread group. Right click on it and add a View Result Tree (Add -> Listeners -> View Result Tree), a View Results in Table (Add -> Listeners -> View Results in Table) and an Aggregate Graph (Add -> Listeners -> Aggregate Graph). The first one is to check the result of each HTTP request,
the second one to have the load test data in tabular format
and the third one to generate a chart
At the end the test plan should look like the following:
You can execute it the usual way for any JMeter test plan. As suggested by the JMeter documentation, please don't use the GUI to run regular load testing on a system, but use the CLI or automate the execution through Maven and Jenkins as described in this article.
We covered here the basics to create a template test plan for load testing InfluxDB instances: next, I am going to cover more advanced concepts in a separate article.
Opinions expressed by DZone contributors are their own.