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. window下安裝redis服務

    一.下载windows版本的Redis github下载地址:https://github.com/MicrosoftArchive/redis/releases/tag/win-3.2.100   ...

  2. 分享会上演示Dubbo的路由规则,结果被小坑了下

      今天公司给大家演示基于Dubbox的服务治理平台,结果因为开了vpn导致本机IP地址比较混乱,在配置路由规则的时候我这样配置条件路由 consumer.host=*.*.*.* => pro ...

  3. tomcat配置访问图片路径映射到磁盘路径

    首先,我在调试页面的时候发现,图片路径为: /webapps/pic_son/img/1234565456.jpg 但是,tomcat中webapps的文件夹下的pic_son项目中,img文件夹是空 ...

  4. nagios无法载入静态资源

    使用nginx+nagios无法载入静态资源,看了下url中增加了一个/nagios 查看是/usr/local/nagios/etc/cgi.conf中url_html_path=/nagios 将 ...

  5. cors实现跨域(.net和jquery)

    本文引用自:http://blog.csdn.net/xuwei_xuwei/article/details/29845865 客户端 一个jquery cors请求例子: $.ajax({     ...

  6. spring mvc:拦截器不拦截静态资源的三种处理方式

    方案一.拦截器中增加针对静态资源不进行过滤(涉及spring-mvc.xml) <mvc:resources location="/" mapping="/**/* ...

  7. python中sorted()函数的用法

    一. 定义 sorted()函数对所有可迭代的对象进行排序操作 二. 语法 sorted(iterable [, key[, reverse]]]) iterable:可迭代对象 key:主要是用来进 ...

  8. easyui-textbox高为0

    之前在项目中也遇到过,一段时间没遇到这种问题居然又忘记了,想着还是在博客中记录一下,方便自己记忆,也供大家参考. 大家是否也遇到过easyui-textbox高为0的情况呢 像这样:  用户名:< ...

  9. 51nod 1326 奇妙的spfa+dp

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1326 1326 遥远的旅途 题目来源: TopCoder 基准时间限制: ...

  10. sizeof结构体

    规则1:结构体的对折长度为其基本数据成员的长度的最大值. 规则2:指定边界情况下,结构体的对折长度为自身对折长度和指定对折长度中较小者. 规则3:当行内结构体的基本数据成员的起始地址必须为其长度的整数 ...