web流量/镜像复制工具——gor

来源:互联网 发布:如何提高淘宝店铺流量 编辑:程序博客网 时间:2024/06/10 15:06

web架构设计中围绕的最重要的问题就是流量。在网站初期没有流量的时候,需要线上真实的流量对系统做压力测试。而在网站后期流量起来之后,又需要在不影响线上服务的情况下,导入线上流量来验证所发布系统的相关性能表现。


传统压力测试工具,如ab(apache benchmark)http_load等,都是模拟一些用户的服务请求,不能还原真实的场景,往往有请求过于单一、网络过于理想化等问题。


而流量复制/镜像类工具,则是通过对线上真实流量放大和缩小来引入测试流量,常见的有gortcpcopy


gor的官方网站:

https://github.com/buger/gor/releases


将8000端口的流量输出到终端上

sudo ./gor --input-raw :8000 --output-stdout


8000端口的流量镜像到http://localhost:8001

sudo ./gor --input-raw :8000 --output-http="http://localhost:8001"


8000端口的流量镜像到本地文件

sudo ./gor --input-raw :8000 --output-file=requests.gor


从文件中镜像流量到http://localhost:8001

./gor --input-file requests.gor --output-http="http://localhost:8001"


改变流量的header

gor --input-raw :80 --output-http "http://staging.server" --output-http-header "User-Agent: Replayed by Gor"


镜像5%的流量

sudo ./gor --input-raw :8001 --output-http "http://192.168.254.203:80|5%"


只镜像特定规则url的请求

sudo ./gor --input-raw :8001 --output-http http://192.168.254.203:80 -http-allow-url get-info

0 0
原创粉丝点击