校验系统的准确性和可靠性时,仅靠用例场景无法覆盖全生产环境的所有场景,需要一套引流工具,在系统正式上线前,用线上的请求测试待上线系统,在正常的请求下,是否会有报错,在数倍请求下,系统的性能瓶颈。使用了引流工具goreplay,原名叫gor
nohup ./gor --input-raw :8080 --output-file /home/work/gor/logs/gor-request.gor --output-file-append &
./gor --input-file "/home/liruigao/tools/gor/hisearch/gor_197.gor|100%" --input-file-loop --output-http="baidu.com"
-input-raw-track-response
If turned on Gor will track responses in addition to requests, and they will be available to middleware and file output
-output-file-append
The flushed chunk is appended to existence file or not.
-output-file-max-size-limit value
Max size of output file, Default: 1TB (default -1)
--http-allow-url #允许正则匹配的url
--http-disallow-url #不允许正则匹配的url
--http-allow-method #允许的请求方法,传入值为GET、POST等
限速
./goreplay --input-tcp :28020 --output-http "http://staging.com|10"# (每秒请求数限制10个以内)
sudo ./goreplay --input-raw :80 --output-tcp "replay.local:28020|10%" # (每秒请求数限制10%以内)
--input-raw #用来捕捉http流量,需要指定ip地址和端口
--input-file #接收通过--output-file保存流量的文件
--input-tcp #将多个 Goreplay 实例获取的流量聚集到一个 Goreplay 实例
--output-stdout #终端输出
--output-tcp #将获取的流量转移至另外的 Goreplay 实例
--output-http #流量释放的对象server,需要指定ip地址和端口
--output-file #录制流量时指定的存储文件
详见:https://ceshiren.com/t/topic/9027
https://www.cnblogs.com/sunsky303/p/9072871.html
网友评论