Reputation: 1331
I've got a project to work on and I need to build some client - server applications where I can send messages and whatever, in Java. One goal of the project is to deal with failover. When a client is connect to a server and the server dies, it automatically connects to the backup server. What I want to do is not required but I want to implement a load balancer so multiple clients get connected to the prefered server.
The connection between a client and the server must be with TCP sockets.
This is a schematic of the network architecture:
client connects to the load balancer (udp or tcp, I don't know the best one for this situation).
load balancer decides the which server should that client connect (the most empty one)
the client creates a TCP connection with the specified server
My question is:
How should the load balancer work to get a client to connect to specific server? Send information of the server (ip, port) to the client and the clients creates another socket with the new ip? (blue line).
Or is there a way for the load balancer to connect those two end points (server #1 <-> client #1), without having to send information to the client?
PS: I'm asking you because it seems unnecessary for each client to have to create 2 sockets to get connect to the server (first socket black line, second socket blue line)
Upvotes: 1
Views: 3082
Reputation: 205
i think after the client sends information to the load balancer,its best if the load balancer sends that information to the server which it decides instead of sending something back to client and client connecting again to server
Upvotes: 1