JMeter & Redis
Learn how to integrate Apache JMeter with Redis for dynamic test data management, enabling you to modify datasets during live performance tests.
Mark
Performance Testing Expert
This technical guide explores how Apache JMeter integrates with Redis for enhanced test data management.
Overview
Traditionally, Apache JMeter manages test data through CSV files. However, the Redis Data Set plugin offers an alternative approach, enabling users to amend the data set used in a JMeter test plan while a test is in-flight.
What is Redis?
Redis is an in-memory data structure store, used as a database, cache and message broker. A key advantage is dynamic data modification during active testing.
Installation
JMeter Plugin
- Download
plugins-manager.jarfrom jmeter-plugins.org - Place in
lib/extdirectory - Restart JMeter
- Access Options > Plugins Manager > Available Plugins
- Search for “Redis” and select “Redis Data Set”
- Apply changes and restart
Redis
Download and install from redis.io for your operating system.
Practical Implementation
First, create a Redis key containing your test data using LPUSH commands:
redis-cli LPUSH martkosit "Sheffield"
redis-cli LPUSH martkosit "Leeds"
redis-cli LPUSH martkosit "Cardiff"
redis-cli LPUSH martkosit "Manchester"
redis-cli LPUSH martkosit "London"
Configuration
In JMeter, configure the Redis Data Set:
- Redis Key:
martkosit - Variable Names:
city - Redis server host:
localhost
Using the Variable
The Dummy Sampler references the variable using ${city} syntax to retrieve values dynamically.
Dynamic Data Sets
The real power of this approach is adding new values while tests execute:
redis-cli LPUSH martkosit "New York"
redis-cli LPUSH martkosit "L.A"
redis-cli LPUSH martkosit "Boston"
New data is immediately accessible to running threads. This enables dynamic data sets to a live test and supports scenarios like extending datasets or removing problematic values.
Further Reading
Tags: