1. 项目地址
https://github.com/buger/goreplay
2. 安装
wget https://github.com/buger/goreplay/releases/download/v0.16.1/gor_0.16.1_x64.tar.gz
tar xvf gor_0.16.1_x64.tar.gz
cp goreplay /usr/bin
3. 简单使用
//  测试环境使用的是nginx 有连个机器一台进行反向代理,具体的安装配置比较简单

a. 进行流量拷贝并输出到标准输出
goreplay --input-raw :80 --output-stdout
response message
GET / HTTP/1.1
Host: XXXXXXXXX
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cache-Control: max-age=0
If-Modified-Since: Sat, 04 Nov 2017 13:52:14 GMT
If-None-Match: W/"59fdc60e-232"
Proxy-Connection: keep-alive
Upgrade-Insecure-Requests: 1
X-Forwarded-For: XXXXXXXXX
X-Lantern-Version: 4.4.0 b. 流量拷贝其他环境 goreplay --input-raw :80 --output-http="http://xxxxx:port" c. 流量拷贝存储为本地文件(也可以使用s3存储,开源的有minio) copy:
goreplay --input-raw :80 --output-file=requests.gor
replay:
goreplay --input-file requests.gor --output-http="http://XXXXXXXX:port"
4. 可用的插件
a. input 

--input-raw - used to capture HTTP traffic, you should specify IP address or
interface and application port. More about Capturing and replaying traffic.
--input-file - accepts file which previously was recorded using --output-file.
More about Saving and Replaying from file
--input-tcp - used by Gor aggregation instance if you decided forward traffic
from multiple forwarder Gor instances to it. b. output --output-http - replay HTTP traffic to given endpoint, accepts base url
--output-file - records incoming traffic to the file. More about Saving and Replaying from file
--output-tcp - forward incoming data to another Gor instance, used in conjunction with --input-tcp. Read more about Aggregator-forwarder setup.
--output-stdout - used for debugging, outputs all data to stdout.
5. 扩展
Rate limiting

a. Limiting replay using absolute number

# staging.server will not get more than ten requests per second
gor --input-tcp :28020 --output-http "http://staging.com|10" b. Limiting listener using percentage based limiter # replay server will not get more than 10% of requests
# useful for high-load environments
gor --input-raw :80 --output-tcp "replay.local:28020|10%" c. Consistent limiting based on Header or URL param value # Limit based on header value
gor --input-raw :80 --output-tcp "replay.local:28020|10%" --http-header-limiter "X-API-KEY: 10%" # Limit based on header value
gor --input-raw :80 --output-tcp "replay.local:28020|10%" --http-param-limiter "api_key: 10%" Request filtering a. Allow url regexp # only forward requests being sent to the /api endpoint
gor --input-raw :8080 --output-http staging.com --http-allow-url /api b. Disallow url regexp # only forward requests NOT being sent to the /api... endpoint
gor --input-raw :8080 --output-http staging.com --http-disallow-url /api c. Filter based on regexp of header # only forward requests with an api version of 1.0x
gor --input-raw :8080 --output-http staging.com --http-allow-header api-version:^1\.0\d # only forward requests NOT containing User-Agent header value "Replayed by Gor"
gor --input-raw :8080 --output-http staging.com --http-disallow-header "User-Agent: Replayed by Gor" d. Filter based on HTTP method gor --input-raw :80 --output-http "http://staging.server" \
--http-allow-method GET \
--http-allow-method OPTIONS
6. 参考资料
// wiki
https://github.com/buger/goreplay/wiki
https://github.com/buger/goreplay
// kafka
https://github.com/buger/goreplay/wiki/Streaming-from-and-to-Apache-Kafka
// Distributed-configuration
https://github.com/buger/goreplay/wiki/Distributed-configuration
 
 
 
 

goreplay(gor) golang 流量拷贝工具试用的更多相关文章

  1. nginx 流量拷贝模块 ngx_http_mirror_module 安装试用

    1. 下载源码编译 https://nginx.org/download/nginx-1.13.4.tar.gz   2. 下载依赖模块包       这里直接yum 安装 yum -y instal ...

  2. 10 个强大的开源 Web 流量分析工具(转帖)

    Web 流量分析工具多不胜数,从 WebTrends 这样专业而昂贵的,到 Google Analytics 这样强大而免费的,从需要在服务器端单独部署的,到可以从前端集成的,不一而足.本文收集并介绍 ...

  3. [性能] Bean拷贝工具类性能比较

    Bean拷贝工具类性能比较 引言 几年前做过一个项目,接入新的api接口.为了和api实现解耦,决定将api返回的实体类在本地也建一个.这样做有两个好处 可以在api变更字段的时候保持应用稳定性 可以 ...

  4. 两款HTTP流量分析工具HttpWatch与Fiddler的比较(转)

    最近突然想看看HTTP的消息到底是怎么回事,在网上搜了几款软件来监控,并且搜到了下面的文章,感觉介绍的不错,就copy下来了.下文摘自:http://www.imkevinyang.com/2009/ ...

  5. Github 开源:高效好用的对象间属性拷贝工具:升讯威 Mapper( Sheng.Mapper)

    Github 地址:https://github.com/iccb1013/Sheng.Mapper 对象属性值映射/拷贝工具.不需要创建映射规则,不要求对象类型一致,适用于简单直接的拷贝操作,可以全 ...

  6. 对象属性拷贝工具类大全==>Bean的属性拷贝从此不用愁

    大家在做java开发时,肯定会遇到api层参数对象传递给服务层,或者把service层的对象传递给dao层,他们之间又不是同一个类型对象,但字段又是一样,如果还是用普通的get.set方式来处理话,比 ...

  7. golang学习笔记11 golang要用jetbrain的golang这个IDE工具开发才好

    golang学习笔记11   golang要用jetbrain的golang这个IDE工具开发才好  jetbrain家的全套ide都很好用,一定要dark背景风格才装B   从File-->s ...

  8. java bean属性拷贝工具类比对(性能+功能)

    业务系统中经常需要两个对象进行属性的拷贝,不能否认逐个的对象拷贝是最快速最安全的做法,但是当数据对象的属性字段数量超过程序员的容忍的程度比如通常超过5个属性的时候,代码因此变得臃肿不堪,使用一些方便的 ...

  9. APP的CPU,内存,耗电,流量测试工具

    APP的CPU,内存,耗电,流量测试工具下载地址,后续文章会介绍如何使用Emmagee.itest.gt APP应用的CPU,内存,耗电,流量调查 可和同类产品比较,使用GT等工具:CPU靠syste ...

随机推荐

  1. 如何修改Django中的日期和时间格式 DateTimeField

    html页面从数据库中读出DateTimeField字段时,显示的时间格式和数据库中存放的格式不一致,比如数据库字段内容为2017-06-03 13:00:00,但是页面显示的却是Apr. 03, 2 ...

  2. Lily hbase indexer搭建配置概要文档

    1.solrcloud搭建好2.hbase-solr-indexer服务开启3.确定hbase中的对应的表开启replication功能 create '} // 1表示开启replication 已 ...

  3. SpringBoot Bean作用域

    Bean在一般容器中都存在以下2种作用域: singleton 默认值,IoC容器只存在单例 prototype 每当从IoC容器中取出一个Bean,则创建一个新的Bean 在Web容器中存在4种作用 ...

  4. Linux 一键安装最新内核并开启 BBR 脚本

    原文链接   https://teddysun.com/489.html 请到原文链接仔细阅读后操作.建议查看过脚本内容后操作,方便理解运行过程. 使用root用户登录,运行以下命令: wget -- ...

  5. ATCODER ABC 099

    ATCODER ABC 099 记录一下自己第一场AK的比赛吧...虽然还是被各种踩... 只能说ABC确实是比较容易. A 题目大意 给你一个数(1~1999),让你判断它是不是大于999. Sol ...

  6. JSP报错01

    ZC: 创建一个JSP之后,就报如下错误. 1.错误: 1.1. 2.处理: Exlipse for JEE --> Project Explorer 中选择项目 --> 右击项目名 -- ...

  7. git常用操作 配置用户信息、拉取项目、提交代码、分支操作、版本回退...

    git常用操作 配置用户信息.拉取项目.提交代码.分支操作.版本回退... /********git 配置用户信息************/ git config --global user.name ...

  8. IDL语言开发规范

    一.支持的类型 1.IDL支持常见的基本类型,常量,枚举,容器,结构体,服务.不支持多态和重载,参数.返回值不能为空,各个基本类型的标识如下: bool:对应java的boolean,布尔类型(tru ...

  9. [转载]java在线比较两个word文件

    一.项目背景 开发文档管理系统或OA办公系统的时候,实现在线处理word文档的功能比较容易,但是也经常会有客户提出文档版本管理的需求,这就需要同时在线打开两个word文件,对比两个不同版本的word文 ...

  10. HTML 中 id与name 区别

    一个name可以同时对应多个控件,比如checkbox和radio而id必须是全文档中唯一的 id的用途1) id是HTML元素的Identity,主要是在客户端脚本里用.2) label与form控 ...