当前位置:网站首页>10 minutes to understand how JMeter plays with redis database
10 minutes to understand how JMeter plays with redis database
2022-07-25 06:41:00 【Program yuanyuexia】
Jmeter As a very popular tool for interface testing and performance testing , It is widely used in enterprises , and redis As a cache database , It is also widely used in enterprises , How to use jmeter To test redis Database ? Today we will talk about how to use jmeter To call redis.
jmeter Get ready
because jmeter It doesn't carry redis Test entry for , We need to install redis plug-in unit .
First , We download jmeter-plugins-manager-1.6.jar file , Put it in jmeter Of lib Of ext In the folder , And then restart jmeter.
then , stay ‘ Options ’ Under menu , Click on ‘plugin manager’, Open the plug-in management pop-up window , choice ‘Available Plugins’, In the search box , Input redis

then , Choose ‘Redis Data Set’, Click on ‘Apply Changes and Restart JMeter’
Restart after automatic download jmeter.
then , stay jmeter Right click on the thread group of , add to > The configuration element > [email protected] - Redis Data Set

here , You can pass jmeter configure connections redis Database . If you already have redis database , Then you can directly configure it in the current interface , If you haven't redis database , You need to install redis database .
install redis database
install redis There are many ways to build a database , That use docker How to install , It's probably the simplest , I'll use docker To install redis database .
docker run -itd --name jmeter-redis \
-p 6779:6379 \
daocloud.io/library/redis:3.2.8-alpine redis-server --appendonly yes
Okay , There is now a redis database , It's time to insert some data into the database .
# Into the container
docker exec -it jmeter-redis /bin/sh
# Command mode , Connect redis
redis-cli
# Insert list data
lpush course jmeter,loadruner
lpush course wrk,ab
lpush course locust,ngrinder

Now? ,redis In the database , There is already a list course, We can do it in jmeter in , Get its data .
jmeter Use redis data
stay RedisDataSet Configuration information in

- Data Configuration Redis key:Redis Medium key,Redis List in database ( Ordered data ) Or set ( Out of order data ) The name of Variable Names: The name of the variable exported from the dataset to the test element ( Set the extracted value In which variable ) Delimiter: Stored in Redis The separator used in a row in a list or collection ( Take out value When there are multiple values , Separator between variable names ) Date Sources Type: Data source type , Yes List、Set Two options Recycle data on Flase: Whether the data is reused
- Connection Configuration Redis server host:Redis The server IP Address Redis server port:Redis Service port Timeout for connect in ms: Connection timeout , Default 2000 ms Password for connection: Connect Redis Password Database: Database name , Connect Redis The first database , The default is 0
- Redis Pool Configuration
Field | usage | The default value is |
minIdle | At least how many are idle redis example | 0 |
maxIdle | How many are idle in a thread pool at most redis example | 10 |
maxActive | Control one pool How many can be allocated redis example , adopt pool.getResource() To get ; If the assignment is -1, It means no limit ; If pool Has been allocated maxActive individual jedis example , Now pool The state of is exhausted | 20 |
maxWait | Said when borrow One redis When an instance , Maximum waiting time , If the wait time is exceeded , And just throw it out JedisConnectionException | 30000 |
whenExhaustedAction | Said when pool Medium redis All examples are allocated At the end ,pool What to do ; There are three kinds of defaults WHEN_EXHAUSTED_FAIL( It means nothing redis When an instance , Direct selling NoSuchElementException)、WHEN_EXHAUSTED_BLOCK( It means blocked , Or achieve maxWait Throw when JedisConnectionException)、WHEN_EXHAUSTED_GROW( It means to create a new jedis example , That is to say, the setting maxActive It's useless ) | GROW |
testOnBorrow | stay borrow One redis When an instance , In advance or not alidate operation ; If true, Obtained redis Instances are available | False |
testOnReturn | stay return to pool when , In advance or not validate operation | False |
testWhileIdle | If true, That means there is a idle object evitor The thread of idle object scan , If validate Failure , this object Will be from pool in drop fall ; This term is only in timeBetweenEvictionRunsMillis Greater than 0 Only when makes sense | False |
timeBetweenEvictionRunsMillis | Express idle object evitor Between scans sleep Millisecond count | 30000 |
numTestsPerEvictionRun | Express idle object evitor Maximum number of objects per scan | 0 |
minEvictableIdleTimeMillis | Means that an object at least stays in idle The minimum time of a state , And then to be idle object evitor Scan and expel ; This term is only in timeBetweenEvictionRunsMillis Greater than 0 Only when makes sense | 60000 |
softMinEvictableIdleTimeMillis | stay minEvictableIdleTimeMillis On the basis of , Joined at least minIdle The object is already in pool Inside the . If -1,evicted Will not be based on idle time Expel any object . If minEvictableIdleTimeMillis>0, Then this setting has no meaning , And only in timeBetweenEvictionRunsMillis Greater than 0 Only when makes sense | 60000 |
Next, we add a debug sampler , Reference... In name redis Variable name . then , The number of thread group cycles is set more than once .

function

We see , To obtain the redis The data of .
jmeter towards redis Write data in
The above? , We have already talked about , How to get redis Data in the database ? What about next , Let's talk about how to redis Write data in the database .
First , We download jedis Of jar package , Put the downloaded package , Put in jmeter Of lib Under the folder , restart jmeter
then , stay jmeter in , Add a thread group , add to ‘jsr223 sampler’
import redis.clients.jedis.Jedis;
Jedis jedis = new Jedis("81.69.228.171", 6679);
jedis.set("foo","bar");
String value = jedis.get("foo");

Run script

from redis Confirm in the database , The data has been warehoused

Okay , adopt jmeter The methods of writing data and obtaining data are discussed , Have you learned ?
边栏推荐
- Ant design input search box listens for allowclear event separately
- js数据类型的判断——案例6精致而优雅的判断数据类型
- [datawhale202207] reinforcement learning: the foundation of reinforcement learning
- Bubble sort code implementation
- 【transformer】DeiT
- [datawhale202207] reinforcement learning: strategy gradient and near end strategy optimization
- 杜教筛
- Jstat command summary [easy to understand]
- JVM tuning summary -xms -xmx -xmn -xss
- 常吃发酵馒头是否会伤害身体
猜你喜欢

HTX00001_ Keil51 bug encountered in serial port parsing

RecycleView实现item重叠水平滑动

C control open source library: download of metroframework

你了解PowerBI中的去年同期吗

100 GIS practical application cases (seventeen) - making 3D map based on DEM

Labelme labels different objects, displays different colors and batch conversion

JSON、

【C】程序环境和预处理

JTAG debugging source level debugging of arm bare board debugging

GIS实战应用案例100篇(十七)-基于DEM制作三维地图
随机推荐
[sword finger offer] analog implementation ATOI
Create a new STM32 project and configure it - based on registers
Android interview question: why do activities rebuild ViewModel and still exist—— Jetpack series (3)
CRC8 CRC16 table lookup method
MySQL index collation summary
Standard C language 89
Insight into mobile application operation growth in 2022 white paper: the way to "break the situation" in the era of diminishing traffic dividends
[unity3d] ugui callback function
Koa2 learning
Some common interview questions about IO stream and string
Dry goods | training AI model can't find data? Collect 20 selected open source communities!
Easy to use code statistics tool
The most comprehensive multi-threaded application tutorial - summary in detail
R strange grammar summary
mysql 查询当前数据库下的表名
100 GIS practical application cases (seventeen) - making 3D map based on DEM
JS 获取鼠标选中的文字并处于选中状态
代码中的软件工程:正则表达式十步通关
Do you know the same period last year in powerbi
Simple factory factory method Abstract Factory