Is it possible to duplicate network traffic from port to 2 different machines


In first I will try to describe the problem.
We use following network configuration:

  • machine1 with installed haproxy
  • machine2 with application(in this case we can assume that is only RabbitMq service)
  • machine3 as test server(copy of machine2)

All traffic goes to port(777 for example) of machine1. Haproxy redirect traffic to port(888 for example) of machine2. Application on machine2 listen port 888 and process requests.
Also we have machine3 as test server and when we prepare next release we want to test it with real load.

So question now: is posible to duplicate incoming network traffic from port 777 of machine1 to port 888 of machine2 and(somitemes, when we need that) to port 888 of machine3?

PS Sorry for my bad English

Best Answer

If your traffic uses TCP for communication, any Layer 2 traffic duplication won't work. This is because TCP handshake is a bi-directional process, where client needs to send back response packets to the client.

If such traffic duplication is done on a higher level, the issue is responses to clients. If two server's receive the same traffic, and both send responses back, which response should be sent?

You should be able to set traffic processing rules in HAProxy, which divides traffic between servers. This way you can get real traffic to the test server.

However, sending production users to test servers is not a good idea.

The only good solution is to set up proper load-testing using tools designed for it. With the tools, you can set up test scenarios for load testing, and the perform requests like real clients.

Related Topic