Performance testing tool - installation and use of wrk

foreword

I want to talk about performance testing with you. When it comes to performance testing, I must talk about the tools in performance testing. Among these tools, I will mainly introduce wrk to you today.

​Introduction

wrk is an open source performance testing tool that is easy to use and not as complicated as Load Runner. It is a performance testing tool like apache benchmark (ab), but it is more powerful than ab and can support lua scripts to create complex tests. Scenes.

A good feature of wrk is that it can squeeze out a large amount of concurrency with few threads, because it uses some operating system-specific high-performance I/O mechanisms, such as select, epoll, kqueue, etc. In fact, it reuses the ae asynchronous event-driven framework of redis. To be precise, the ae event-driven framework is not invented by redis, it comes from the Tcl interpreter jim, this small and efficient framework, because it is adopted by redis, and more is well known. 

Install

wrk can only run on Unix-like systems, and it can only be cheap on these systems, so we need a Linux or macOs.

I have to say that it is much more convenient after using Win10.

Prerequisites:

  • Win10 RS and above
  • Enable the Ubuntu subsystem

1. The Win10 system switches to the Ubuntu subsystem through the bash command. Then you need to install the compilation tool, by running the following command to install the tool:

# 安装 make 工具
sudo apt-get install make
 
# 安装 gcc编译环境
sudo apt-get install build-essential
When installing the gcc compilation environment, it is best to connect to the VPN, the speed will be faster.

 

2. After the installation is complete, use git to download the source code of wrk to the local.

3. Switch to the wrk directory of git, and then use the make command:

cd /mnt/drive letter/wrk directory

make

 

After the compilation is complete, there will be a wrk file under the directory.

test

Use the following command to test it out:

./wrk -c 1 -t 1 -d 1 http://www.baidu.com

 

​Briefly talk about what the parameters in wrk mean?

  • -t number of threads to simulate

  • -c number of connections to simulate

  • --timeout timeout time

  • -d duration of the test

result:

  • Latency: response time

  • Req/Sec: The number of completed requests per second per thread

  • Avg: average

  • Max: maximum

  • Stdev: standard deviation

  • +/- Stdev: plus or minus one standard deviation ratio

If the standard deviation is too large, it means that the dispersion of the sample itself is relatively high. It is possible that the system performance fluctuates greatly. If you want to see the distribution of response time, you can add the --latency parameter

We need to pay attention to our simulation test. Generally, the number of threads should not be too many, and 2 to 4 times the number of cores is enough. If there are too many, the efficiency will be reduced due to excessive thread switching, because wrk does not use the model of one thread per connection, but improves the concurrency through asynchronous network I/O. So network communication will not block thread execution, which is why wrk can simulate a large number of network connections with few threads.

Among the test results of wrk, there is an item called Requests/sec, which we generally call QPS (requests per second), which is a performance indicator of a stress test. Through this parameter, we can see the throughput of the application.

Summarize 

Finally, I would like to thank everyone who has read my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, you can take it away if you need it:

These materials should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey, and I hope it can help you! Partners can click the small card below to receive 

 

Guess you like

Origin blog.csdn.net/hlsxjh/article/details/131584232