Transform open source tool - flow playback tool goreplay supports pressure measurement statistics

original
2020/06/23 09:28
Reading 2.3K

Back view

At present, the routine performance test of the input method server mainly uses the open-source traffic playback tool goreplay, which is used for traffic playback, and can also be reduced or amplified when playing back traffic to achieve the purpose of performance testing. But it is not a professional tool for performance testing after all, as the saying goes, "It is not his job but his job", Therefore, goreplay is not very good at result statistics. In order to enable it to support client statistics, we need to upgrade it;

Goreplay's own statistics

He said that he did not support result statistics, but he was wronged. The command line of goreplay also supports result statistics. The parameters are: --stats --output-http-stats After adding this command line, the console output is as follows:


The penultimate column is the same as the current QPS, but this is the only statistical item, and there is no distinction between return code, response time, TP90, TP99 and other indicators;

Prometheus

Official website explanation: open source monitoring solution

metrics

The monitoring data source of prometheus. For detailed explanation, please refer to https://www.investopedia.com/terms/m/metrics.asp

Transformation objectives

Let goreplay support real-time metrics statistics. When goreplay performs traffic playback and performance testing, it counts the current QPS, response time and other indicators of goreplay as the pressure test client in real time;

Implementation process

  1. Analyze the source code and find the function that sends the request in the source code;

  2. To obtain the request status code and the corresponding QPS, insert the counter metric at the position where the request return value is obtained;

  3. In order to obtain the response time of different requests and other indicators, it is necessary to record the starttime before sending the request, the endtime after returning the request, and the histogram metric of time consumption;

  4. After goreplay is started, register the metrics interface and the service listening port;

  5. The metrics service of the goreplay client is registered in the prometheus service;

  6. Establish a dashboard in grafana system to count the data indicators required;

effect

  1. Add metrics related code to http_client.go in the source code (see the end of the text for the source code address)

  2. main.go conduct Metrics registration;

  3. Register goreplay_client metrics in the prometheus configuration file

  4. You need to add a command line when starting goreplay -output-http-compatibility-mode true Statistics based on startup results;

  5. When starting goreplay, check the listening port and find that there is a registered 28081

  6. Interface access http://10.1xx.xx.xx:28081/metrics

  7. Performance test indicators required for creating a new dashboard query in grafana:

So far, the transformation of goreplay has been completed. Through metrics, various indicators in the process of pressure testing have been counted from the client;

Source code address. Since the branch submission needs to be reviewed by the goreplay author, a new project has been created on github, which can be downloaded and used https://github.com/lidedede/gor

among gor_ldd It is the binary compiled by centos7 and can be used directly; Complete command line attached: ./gor_ldd --input-file "xxx.gor|1500%" --output-http http://10.1xx.xx.xx:1xxx --stats --output-http-stats --input-file-loop -output-http-workers 10000 -output-http-workers-min 5000 -output-http-compatibility-mode true

This article is shared from the WeChat official account Sogou QA.
In case of infringement, please contact support@oschina.cn Delete.
Participation in this article“ OSC Source Innovation Plan ”, welcome you to join us and share with us.

Expand to read the full text
Loading
Click to join the discussion 🔥 (1) Post and join the discussion 🔥
one comment
zero Collection
zero fabulous
 Back to top
Top