Use Jmeter to read and use Redis data

Table of contents

foreword

cache

Redis service and client installation

Jmeter uses Redis


foreword

When doing performance testing with JMeter, it is sometimes necessary to read and use Redis data. Redis is an open source memory data storage system, which is often used in scenarios such as cache, message queue and data storage.

cache

Web systems usually use databases to store data , but database access involves disk reads and writes, and disk IO reads and writes are significantly slower than memory reads and writes. When the amount of concurrency is large, it is easy to become a system bottleneck. In order to improve data access speed and avoid system bottlenecks, more and more web systems have introduced cache databases. At present, the mainstream cache databases include Redis and MongoDB. Jmeter supports database reading of these two memory databases through extension plug-ins. This article takes Redis as an example to introduce how to use Jmeter to read and use Redis data .

Redis service and client installation

1. Download the Redis installation file from the official website

https://github.com/microsoftarchive/redis/releases

2. Double-click the redis-server.exe file on the Windows platform to start the Redis service, and the following prompt will appear on the console, indicating that Redis-Server is successfully enabled

3. Download and install the Windows client, double-click to run it, and the following interface appears; add data in the Redis database through the client, this example adds a List type of data, key=testList, and the value has three types: a, b, and c

Redis is an in-memory database, which is different from the table structure of relational data such as Mysql. Redis has the following six data structures:

  • String: Key-Value manages key-value pairs.
  • Set: An unordered collection of String type, the members of the set are unique, and duplicate data cannot appear in the set.
  • List: A list of strings, sorted by insertion order.
  • Hash: Redis hash is a mapping table of string type field and value, and hash is especially suitable for storing objects.
  • Sorted Set: Like a set, an ordered set is also a collection of string type elements. The difference is that each element is associated with a double type score. Redis uses the score to sort the members of the set from small to large.

Jmeter uses Redis

Open the JMeter Plugins Manager and download the Jmeter Redis Data Set plugin

After restarting Jmeter, you can find the new component jp@gc-Redis Data Set in the configuration component  . Jmeter's Redis Data Set currently has some limitations, and only supports List and Set types of data; if you want to process other types of data, you can Write code to read Redis data through Beanshell Sampler.

Redis Data Set can read the data in Redis and store the data as variables for subsequent use. The key configurations are:

  • Redis Key: corresponds to the Key in the Redis database.
  • Variable Name: The variable stored after fetching data from the Redis database can be used by subsequent scripts of Jmeter.
  • Delimiter: Delimiter, the default is , .
  • Data Source Type: Redis data type, only List and Set are supported here.
  • Recycle data on use: Whether to restart the cycle when the data is traversed.
  • Connection Configuration: The configuration information of the Redis server, including the IP, port, timeout, password and database name of the Redis server.
  • Redis Pool Configuration: Redis connection pool configuration.

This example reads the testList data of the local Redis database, and takes out the data as keywords for Baidu search

Click Run, the script can fetch data from the Redis database and use it as an input parameter for subsequent Http requests

Jmeter is very powerful, especially the support for a variety of middleware, please use it quickly.

 As someone who has been here, I also hope that you will avoid some detours. Here I will share with you some necessities on the way forward for automated testing, hoping to help you. (WEB automated testing, app automated testing, interface automated testing, continuous integration, automated test development, big factory interview questions, resume templates, etc.), I believe it can make you better progress!

Just leave [Automated Test] [Automated Test Communication]: 574737577 (remark ccc) icon-default.png?t=N5K3http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=mDKyfdjYNAeufGp8xdITLYX82oszfcAW&authKey=WrZ1YMYKla5sOgXugyqBWmcAJglmktIVxA fVRtY1Hwt1Y7JTcse%2BT6u5PiF1D9aw&noverify=0&group_code=574737577

 

 

Guess you like

Origin blog.csdn.net/Free355/article/details/131500584