goreplay(gor) golang 流量拷贝工具试用
https://github.com/buger/goreplay
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
// 测试环境使用的是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"
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.
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
// 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 流量拷贝工具试用的更多相关文章
- nginx 流量拷贝模块 ngx_http_mirror_module 安装试用
1. 下载源码编译 https://nginx.org/download/nginx-1.13.4.tar.gz 2. 下载依赖模块包 这里直接yum 安装 yum -y instal ...
- 10 个强大的开源 Web 流量分析工具(转帖)
Web 流量分析工具多不胜数,从 WebTrends 这样专业而昂贵的,到 Google Analytics 这样强大而免费的,从需要在服务器端单独部署的,到可以从前端集成的,不一而足.本文收集并介绍 ...
- [性能] Bean拷贝工具类性能比较
Bean拷贝工具类性能比较 引言 几年前做过一个项目,接入新的api接口.为了和api实现解耦,决定将api返回的实体类在本地也建一个.这样做有两个好处 可以在api变更字段的时候保持应用稳定性 可以 ...
- 两款HTTP流量分析工具HttpWatch与Fiddler的比较(转)
最近突然想看看HTTP的消息到底是怎么回事,在网上搜了几款软件来监控,并且搜到了下面的文章,感觉介绍的不错,就copy下来了.下文摘自:http://www.imkevinyang.com/2009/ ...
- Github 开源:高效好用的对象间属性拷贝工具:升讯威 Mapper( Sheng.Mapper)
Github 地址:https://github.com/iccb1013/Sheng.Mapper 对象属性值映射/拷贝工具.不需要创建映射规则,不要求对象类型一致,适用于简单直接的拷贝操作,可以全 ...
- 对象属性拷贝工具类大全==>Bean的属性拷贝从此不用愁
大家在做java开发时,肯定会遇到api层参数对象传递给服务层,或者把service层的对象传递给dao层,他们之间又不是同一个类型对象,但字段又是一样,如果还是用普通的get.set方式来处理话,比 ...
- golang学习笔记11 golang要用jetbrain的golang这个IDE工具开发才好
golang学习笔记11 golang要用jetbrain的golang这个IDE工具开发才好 jetbrain家的全套ide都很好用,一定要dark背景风格才装B 从File-->s ...
- java bean属性拷贝工具类比对(性能+功能)
业务系统中经常需要两个对象进行属性的拷贝,不能否认逐个的对象拷贝是最快速最安全的做法,但是当数据对象的属性字段数量超过程序员的容忍的程度比如通常超过5个属性的时候,代码因此变得臃肿不堪,使用一些方便的 ...
- APP的CPU,内存,耗电,流量测试工具
APP的CPU,内存,耗电,流量测试工具下载地址,后续文章会介绍如何使用Emmagee.itest.gt APP应用的CPU,内存,耗电,流量调查 可和同类产品比较,使用GT等工具:CPU靠syste ...
随机推荐
- sql 加密解密函数
if object_ID ( 'fn_ACITEncryption' ) is not null drop function fn_ACITEncryption go create ...
- Mybatis常见问题
1.#和$的区别和联系 1.1#是占位符,会对Sql进行预编译,相当于?:$是做Sql拼接,有sql注入的隐患 1.2#不需要关注数据类型,Mybatis自动实现类型转换,$必须自己判断数据类型联系 ...
- maven项目包结构
groupId填写公司名称,如com.enn.ennewartifactId填写项目名称webapps如父工程: <groupId>com.enn.ennew</groupId> ...
- API接口幂等性框架设计
表单重复提价问题 rpc远程调用时候 发生网络延迟 可能有重试机制 MQ消费者幂等(保证唯一)一样 解决方案: token 令牌 保证唯一的并且是临时的 过一段时间失效 分布式: redis+to ...
- 逆序对算法(reverse pair)
逆序对(reverse-pair) 思想和归并排序的思想一样,时间复杂度是O(nlgn). 就是在统计逆序对个数的表达式需要注意一下. 具体实现 #include <iostream> # ...
- spark学习12(Wordcount程序之spark-shell)
在目录/home/hadoop/2016113012下有文件words.txt hello scala hello java hello python hello wujiadong 上传该文件到hd ...
- Ext.grid.GridPanel数据转json
var count = docAdGrid.getStore().getCount(); var jsonArray = []; for (var i = 0; i < count; i++) ...
- Rancher + K8S RestApi使用
1前言 1.1使用的软件及版本 软件 版本号 Rancher 1.6stable Kubernetes 1.8.3 Docker 1.12.6 1.2 Rancher与K8S的RESTAPI差异 ...
- css文本(教程)
1.text-transform --文本转换 定义文本的大小写状态,此属性对中文无意义 取值:capitalize | uppercase | lowercase | none | inherit ...
- 剑指offer--32.把数组排成最小的数
用to_string()将整形转化为字符串,对字符串进行比较 --------------------------------------------------------------------- ...