go-stress-testing
Introduction
go-stress-testing is a stress testing tool implemented by the go language. Its source code is open source and supports secondary development. It can stress test http, webSocket requests, and private rpc calls. It uses coroutines to simulate a single user and can use the CPU more efficiently. resource
Instructions
- download link
- Note that the project source code needs to be cloned to the $GOPATH directory
- mac computer download as follows
- Put it in the $GOPATH directory
-
- empower
chmod +x go-stress-testing-mac
- empower
- Execute in this directory
./go-stress-testing-mac
to view usage
Test request Baidu page
./go-stress-testing-mac -c 1 -n 100 -u https://www.baidu.com/
- It's pretty easy to use, and it also supports secondary development
Summary of advantages
- It is easy to use and only needs simple command line parameter settings to complete the stress test.
- Multiple protocols are supported, including HTTP, TCP, UDP, etc.
- The generated reports are intuitive and easy to analyze.
Shortcomings summary
- It has relatively few functions and does not support many advanced features.
fortio
Introduction
Fortio runs at the specified queries per second (qps) and calculates the percentage by recording a histogram of the execution time. (ex: p99, the response time, means that 99% of requests take less than this number). Fortio supports running for a set duration, a fixed number of invocations, or until interrupted.
Fortio is also very fast, lightweight (its docker image is only 4MB, with minimal dependencies), and supports secondary development, supports embedded go libraries, and can be used in the form of command-line tools and server processes. Its services include a simple web UI and REST API for triggering runs and viewing graphical representations of results (including min, max, mean, qps and percentile plots for individual latency graphs and multiple result comparisons)
fortio (httpbin-like) server-side features to help with debugging and testing: request echo (including request headers), add delay or error codes with probability distributions, tcp echo, tcp proxy, http fanout/scatter and gather proxy Server, GRPC echo/health and http etc.
Use and install
- The minimum version of go is 1.18
- install command
go install fortio.org/fortio@latest
- You can also use brew to install
brew install fortio
- You can also use brew to install
- start up
fortio server
- In particular, this command needs to be run in the $GOPATH directory
problems encountered
- Under the MAC system, use
go install fortio.org/fortio@latest
the installationfortio
tofortio
install it to the $GOPATH/bin directory - Move it to
bin
the same level as the directory, run with./fortio server
, you can see the following output - The UI page is displayed as follows
test run
- generated result
Summary of advantages
- Easy to operate with UI interface
- Active community, high attention, guaranteed quality
- Also supports secondary development
- Supports a variety of advanced features, such as distributed stress testing, persistent connection testing, TLS encryption support, etc.
- Simple to use, provides a visual interface, easy to use and analyze.
Shortcomings summary
- The threshold for using is relatively high, and it takes more time to learn and use all English
- For some complex scenarios, it is necessary to write annotations to achieve.
vegeta
Introduction
Vegeta is a general purpose HTTP load testing tool that was built based on the need for an HTTP service with a constant request rate. Available both as a command line and as a library.
Use and install
Install
brew update && brew install vegeta
- The command execution error
- You can execute
brew cleanup
or close the window or wait for a while before installing
- Install using go
go install github.com/tsenart/vegeta@latest
- As follows, the installation is successful
test use
- After the installation is successful,
$GOPATH/bin
you can see the downloaded binary file in the directory - Enter
$GOPATH/bin
the directory and execute./vegeta
to view the help information of the command line
- Steps for usage
- Write test scripts
- Write a file containing all the requests to be tested, such as test.txt Each request occupies one line, the format is as follows
请求方法 URI1
请求方法 URL2
{"post请求": "请求参数"}
- run test
echo "GET [https://www.baidu.com/"](https://www.baidu.com/) | vegeta attack -duration=5s | tee results.bin | vegeta report
- Explanation:
[https://www.baidu.com/](https://www.baidu.com/)
Initiate a 5-second GET request, record the result in the results.bin file, and then display a report on the request - The test results are as follows
- You can see the generated results.bin file in the current directory
Summary of advantages
- It has strong flexibility and can realize stress testing of various complex scenarios through a simple configuration file.
- Supports HTTP/1.1, HTTP/2 and TCP protocols.
- The generated reports are detailed and easy to analyze.
Shortcomings summary
- The learning curve is steep and requires a certain learning cost.
- No visual interface, not very easy to use.
Summarize
Which stress testing tool to choose depends on specific needs and scenarios. If you need to support a variety of advanced features and distributed stress testing, fortio is more suitable. If you need a more flexible testing tool, you can choose vegeta; if your requirements are relatively simple, you can choose go-stress-testing
end flowering
- I wish you a happy life
reference
https://github.com/link1st/go-stress-testing
https://github.com/fortio/fortio
https://github.com/tsenart/vegeta