如何使用生产中的真实数据测试测试环境

如何使用生产中的真实数据测试测试环境

我有以下基础设施:

1x 负载均衡器 (nginx) 4x apache 上游 1x mysql 服务器

该网站非常繁忙,我购买了另外 6 台服务器,用于替换以前的基础设施。

由于设置不同,我想用实时数据透明地测试我的新服务器基础设施。我发现https://github.com/wangbin579/tcpcopy但由于某种原因,它对我来说不起作用(它没有发送 99% 的请求)。

我必须说,我无法物理访问服务器,也无法操作交换机。两台服务器位于两个不同的网络中(但当然,它们可以互相看到)。

谢谢你的时间 :)

答案1

TEE您可以尝试使用 iptables目标在负载均衡器级别复制流量,请参阅iptables(8)手册页:

TEE The TEE target will clone a packet and redirect this clone to another machine on the local network segment. In other words, the nexthop must be the target, or you will have to configure the nexthop to forward it further if so desired.

   --gateway ipaddr
          Send the cloned packet to the host reachable at the given IP address.  Use of 0.0.0.0 (for IPv4 packets) or :: (IPv6) is invalid.

   To forward all incoming traffic on eth0 to an Network Layer logging box:

   -t mangle -A PREROUTING -i eth0 -j TEE --gateway 2001:db8::1

答案2

修复你的日志记录。

最好的方法是使用日志中的实际数据重放流量(可能速度不同)。标准 Apache 日志不够好,因为它们不包含所有标头(假设您的应用程序使用这些标头来向网络爬虫提供简化的页面),也不包含 POST 数据。

因此,请确保您的应用程序正确记录日志并在新设置上重播日志。并 200% 确保您不会发回任何数据,也不会更改实时数据 :)

相关内容