未加星标

JMeter Data sharing now easy with ReDis in distributed load testing

字体大小 | |
[数据库(综合) 所属分类 数据库(综合) | 发布者 店小二05 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

In this article, I would like to show how we can share data among all the JMeterservers in distributed mode.

Problem Statement:
JMeter   Data sharing now easy with ReDis in distributed load testing
If you have been running JMeter in distributed mode, you might already know that setting up all the JMeterservers with all the dependency is a pain. We already see that docker greatly simplifies the JMetermaster and slave setup.

If you have not checked these articles out already, I would suggest you check these first.

Docker JMeter Docker in AWS Docker Compose

However, JMeter master simply runs the .jmx file in all the server machines. If the JMeter test is depending on test data in a CSVfile, then you need to copythe CSV file and distribute yourself to all the JMeterservers. Most of the times, test data used by Slave1 can not be used by other slaves. We also need to ensure that you split the CSV file and distribute to the slaves. Unfortunately docker can not help us here directly with the test data distribution.

CSV in Distributed Mode:

Even if we split the file and moved to the slaves by using a script, still there is a limitation with this approach.

Lets assume, We have 10,000 records to processand wehave 4 slaves. So we split the 10K record CSV file into 4 CSV files with 2500 records each. If the JMeter test is supposed to process all the records, there is a chance that some slaves might have finished the test sooner than others. It happens because each row does not necessarily have to take same amount of time to process by the application under test. So when one of the serversis still processing its 2400th record, another server could have completed all the 2500 records.


JMeter   Data sharing now easy with ReDis in distributed load testing

In the above setup, after some time, we might see some servers have finished the test while other servers still working very hard to finish the test. Even though theseservers are available to help the other servers which are still running, they can not as they do not have the test data.

Pros Fast Cons The huge data file has to be split into multiple files based on the numberof servers we use. File has to be moved to all the slaves either manually / using custom scripts. Each server has its own data. Data sharing among them is not possible. Once the test is started, We can not add more data for the slaves. What is Redis:

Redis stands for RE mote DI ctionary S erver. 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 keepsall 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/writingthe data.

ReDis in Distributed Mode:

Instead of keeping all the test data in a CSV file, splitting them and distribute them We will move all data to Redis DB and Redis will be serving the test data to the JMeter servers. The set up will be as shown here.


JMeter   Data sharing now easy with ReDis in distributed load testing

If you would like to use Redis instead of CSV, you do NOThave to change a lot in your JMeter test. You just need to use “[email protected] Redis Data Set” plugin and update the Redis DB server details in the JMeter test plan. We will be using the same variable names, your JMeter test would not really know who is serving the test data. The test will run just fine.


JMeter   Data sharing now easy with ReDis in distributed load testing

We can also add more data to the ReDisserver while JMeter slaves are running the test.

Pros Data sharing among the slaves are very easy. No need to split the files. Redis serves the data to all the servers. So no need to worry moving the test data to the servers. Load is distributed evenly among the servers. New data can be added to the ReDis server to serve for the JMeter slaves while the test is running. Cons Relatively slow [This slowness is not because of ReDis. It could be due to your network]. JMeter-ReDis Infrastructure Setup: Lets create a docker compose file for our complete JMeter-Redis test infrastructure as shown below. [I assume you already have some idea about docker-compose. If not, Please check this article ] Create a directory.

mkdir tag

Create a new docker-compose file by copying above file content. cd tag sudo vim docker-compse.yml Setupthe entireJMeter-ReDis infrastructure with the belowcommand.

sudo docker-compose up -d

Run the below command to see the running services

sudo docker-compose ps

Name Command State Ports
-----------------------------------------------------------------------------
master /bin/bash Up 60000/tcp
redis docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp
tag_slave_1 /bin/sh -c $JMETER_HOME/bi ... Up 1099/tcp, 50000/tcp Lets add more slaves by issuing below command.

sudo docker-compose scale slave=4

Name Command State Ports
-----------------------------------------------------------------------------
master /bin/bash Up 60000/tcp
redis docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp
tag_slave_1 /bin/sh -c $JMETER_HOME/bi ... Up 1099/tcp, 50000/tcp
tag_slave_2 /bin/sh -c $JMETER_HOME/bi ... Up 1099/tcp, 50000/tcp
tag_slave_3 /bin/sh -c $JMETER_HOME/bi ... Up 1099/tcp, 50000/tcp
tag_slave_4 /bin/sh -c $JMETER_HOME/bi ... Up 1099/tcp, 50000/tcp Lets run one more command to get the all the IP addresses of the slaves.

sudo docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(sudo docker ps -aq)

/tag_slave_2 - 172.19.0.7
/tag_slave_3 - 172.19.0.6
/tag_slave_4 - 172.19.0.5
/master - 172.19.0.4
/redis - 172.19.0.3
/tag_slave_1 - 172.19.0.2 Pushing Data to ReDis:

Now lets move some data to the ReDis DB. Download the Jedis jar and and place it in the classpath create some data. Or Read your CSV file and move the data to ReDis as shown here.

import redis.clients.jedis.Jedis;
Jedis jedis = new Jedis("server

本文数据库(综合)相关术语:系统安全软件

主题: RedisDocker.Net
分页:12
转载请注明
本文标题:JMeter Data sharing now easy with ReDis in distributed load testing
本站链接:http://www.codesec.net/view/484297.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 数据库(综合) | 评论(0) | 阅读(33)