Hi,
Description I have a server that is running and had multiple client connect directly to it by pointing to a specific IP and port number via socket.
The server socket as the listening side and the client uses normal socket.
The server is kinda like a application server that handles my home-brew RPC. Gives the server a message(
string), the server runs it, return whatever result back to the client.
What leads to the problem Now i am thinking of opening another server as a mean of load balancing. However, i do not want to change the coding in client that specifies the connection detail(ip, port)
So i decided to write a proxy server that stands in the previous server ip and port and will "forward/divert" the socket connection to the less busy server.
I had some leads of solution in mind:
Firstly, the message sent by the client have to be read by the proxy server to determine which server it should go to. This part i have no problem since the request wouldn't be as heavy
The Problem: The major problem is if i send the request out using the proxy , the server will response to the proxy, and than the proxy will response to the client directly.
What i want to achieve here is that i wan the proxy to only divert the request and do not do any respond by itself. Which means that each server will get the request from proxy, but will send back the request directly to the client, not the proxy.
Tried (and abandoned) Method I tried to another server socket at the client to listen and include the listening port and ip of the client and made the server to response to the server socket opened at the client, but it is inefficient and incurred too much overhead since 2 extra socket needs to be opened and threads in
java doesn't guarantee the server socket in client will start listening when the server has done processing.