In this post, I would like to show you how to use Redis Data Set Config in JMeter and how it affects the throughput of your test.
Redis:
Redis stands for REmote DIctionary Server. It is an open source in-memory data structure store database. It stores various data structures like String, Map, Lists, Sets etc as Key value pairs. As it is an in-memory database, It keeps all the data in the RAM (but it can also write the data in the disk periodically). So you get significant amount of performance boost while reading/writing the data.
Goal:
My goal here is to see how redis can be used with JMeter to keep my test data instead of a CSV file and to understand the kind of impact I will have in my test when I use Redis instead of CSV!
Why Redis:
Most of us would like to keep the test data for JMeter test in a CSV file. Even though CSV file is a very good choice – by keeping test data away from the test script, It becomes very difficult to manage when you use JMeter in distributed mode. As you probably know, JMeter simply executes the same jmx file in all the slaves. So, the CSV file, which is dependency for your JMeter test, should also be copied to all the slaves by you! Sometimes, the test data used by slave1 should not be used by slave2 [due to your application design]. In this case, you need to split the CSV file into multiple files for each slave and move them to slave machines to run the test successfully.
Redis will be a great choice here in JMeter distributed mode testing as it can serve the data for all the slaves.
CSV Data Set config:
- First I create a very simple CSV file with 100,000 records.
- I create a simple JMeter test to read the CSV file as shown in this picture.
- Now simply run this test in non-gui mode.
- OMG!! JMeter with CSV data set config can read 100K records in a second.
Redis Data Set config:
Now Lets do a similar test using Redis Data Set Config.
- First ensure that you have ‘Redis Data Set Config’ plugin installed.
- At this time of writing this post, JMeter Plugin Manager does not install Redis plugin correctly. The Redis jar is missing a property file. So It does not work.
- Use this link to download the extra lib set. It has the working version of Redis Data Set Config.
- Ensure that You have Redis is installed and are able to access it. Check here for installation.
- Lets create those 100,000 records in Redis as we did for CSV.
- I create a very simple test to use Redis Data Set Config instead of CSV. Everything else remains unchanged.
- Run the test in non-gui mode.
- In my case, JMeter is able to read around 2300 records in a second which is OK.
Note:
- I am sure that the reason behind the bad throughput of Redis is due to network latency as I run Redis server in a separate machine. JMeter connects to redis server for the data.
- I have only one thread running in my JMeter test. So JMeter would have sent 100,000 requests to Redis to read the data sequentially.
- I can do a similar test by running the JMeter and Redis in a same machine where the performance would have been much much better. But my aim is here to see how Redis can be used for JMeter distributed testing. In this case, Redis has to run in a separate machine. That is why I test this way. Please correct me if you think otherwise!!
- I would advise you to do similar test and compare the performance yourself. The result could be completely different for you and vary based on your machine configuration.
Summary:
I expected this result because CSV file is going to be in your local and Redis DB is running somewhere else in my network. Network latency will play significant role in the Redis throughput. So CSV file read will perform better than Redis. However CSV read performs 40X better than Redis which is surprising. I am trying to share this information with you all so that you can be very careful when you create a JMeter test to test a very high throughput application. As I have been saying always we all need to be careful what kind of elements we add to the test.
You might be interested in reading few similar posts.
Happy Testing 🙂