使用代理复制 TCP 流量 [英] Duplicate TCP traffic with a proxy

查看:23
本文介绍了使用代理复制 TCP 流量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从一台机器(端口)和两台不同的机器(端口)发送(重复)流量.我也需要处理 TCP 会话.

I need to send (duplicate) traffic from one machine (port) and to two different machines (ports). I need to take care of TCP session as well.

一开始我使用了 em-proxy,但在我看来开销非常大(它超过了 cpu 的 50%).然后我安装了 haproxy 并设法重定向流量(不要重复).开销合理(小于 5%).

In the beginnig I used em-proxy, but it seems to me that the overhead is quite large (it goes over 50% of cpu). Then I installed haproxy and I managed to redirect traffic (not to duplicate). The overhead is reasonable (less than 5%).

问题是我不能在 haproxy 配置文件中说以下内容:
- 侦听特定地址:端口以及您在两个不同的端口上找到的任何内容机器:移植并丢弃其中之一的答案.

The problem is that I could not say in haproxy config file the following:
- listen on specific address:port and whatever you find send on the two different machines:ports and discard the answers from one of them.

Em-proxy 代码非常简单,但在我看来 EventMachine 生成很多开销.

Em-proxy code for this is quite simple, but it seems to me that EventMachine generates a lot of overhead.

在我挖掘 haproxy 代码并尝试更改(重复流量)之前,我想知道那里有类似的东西吗?

Before I dig in haproxy code and try to change (duplicate traffic) I would like to know is there something similar out there?

谢谢.

推荐答案

我专门为此创建了一个代理.

I have created a proxy just for this purpose.

https://github.com/chrislusf/teeproxy

使用

./teeProxy -l :8888 -a localhost:9000 -b localhost:9001

tee-proxy 是一个反向代理.对于每个传入的请求,它将请求克隆为 2,然后将它们转发到 2 个服务器.来自服务器 a 的结果照常返回,但来自服务器 b 的结果被忽略.

tee-proxy is a reverse proxy. For each incoming request, it clones the request into 2 and then forwards them to 2 servers. The results from server a is returned as usual, but the results from server b is ignored.

tee-proxy 处理 GETPOST 和其他 HTTP 方法.

tee-proxy handles both GET, POST, and other HTTP methods.

这篇关于使用代理复制 TCP 流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆