I’m working on a live client-server system using TCP. The system must ready 24/7 with cut-off time 30 minutes per day.
For some reasons like testing, I want to add some ‘shadow servers’ to the system, so that clients will send request to main server and shadow servers. While the request should be sent to all server, only the reply from main server that matters thus should be sent back to client. Reply from shadow servers should be ignored.
Moreover, starting and stopping shadows server mustn’t do any harm to the system. If a shadows is up, it will receive request, if it’s down, nothing will happen to client-main server.
Is there a way for me to do this without changing either client or main server code?
You can’t do this in client or server code because TCP is point-to-point only.
Perhaps what you want is a “frontend load balancer” that keeps track of what servers are running and forwards incoming requests to one of those.
On the high end, a NetScaler does all this. Though I haven’t personally configured one of these devices, I expect it can have both “primary” and “backup” servers. When I used them, it distributed the load evenly between many servers. It can also be arranged in “high availability pairs” where two of them are connected with one as a “hot standby” in the case where the primary fails.
You probably don’t need anything this sophisticated but it serves to illustrate the point.