Traffic Replication Tool
It can be used to increase confidence in code deployments, configuration changes and infrastrucure changes.
– Goreplay Project
Performance testing is a very important step in the process of service program development. Through this link, we can master the response time, concurrency, swallowing and other performance indicators of the service program, so as to estimate the quality of service of the system, the capacity to carry users and the hardware resources needed, etc.
We can use tools such as AB, WRK, Httperf, Locust, JMeter to simulate user requests, but these simulated requests are not enough to restore the real world, and their request patterns are too simple and idealistic.
To be more realistic, we can replay production environment request logs using “offline replay” tools such as Httperf, vanishReplay, TCPreplay, log-replay, or “traffic copy” tools such as Goreplay, tcpCopy, etc. Capture production environment flow in real time and direct to target test system. At the same time, these “traffic replication” tools can even zoom in and out of real traffic.
Traffic replication tools fall into two categories: traffic replication tools based on application layer and traffic replication tools based on network stack. The former is simple to implement, but will crowd the application resources on the line (such as connection resources, memory resources, etc.), but also may affect the normal business because of high coupling degree. The flow volume replication tool based on the network stack directly captures data packets from the link layer, which has little impact on applications, but its implementation is relatively complicated.
The module ngx_HTTP_mirror_module, introduced in Nginx 1.13.4, is an application-level traffic replication tool. The module [1] currently only implements two configuration instructions, which are quite simple to use:
location / {
mirror /mirror;
proxy_pass
}
location /mirror {
internal;
proxy_pass http://test_backend$request_uri;
}
Copy the code
Each mirror configuration item corresponds to a copy of the user request, so we can configure multiple mirror commands to achieve the effect of “traffic amplification”. Of course, you can also forward multiple copies to different back-end target systems.
Next, take a look at how the module is implemented and what problems it may have from a source code perspective.