WCF, does the Client have to call the Server first

2019-09-18 17:21发布

问题:

Does the Client always have to contact the Service 1st? Would it be possible to specify a specific EndPoint address on the Client, in the Service class, so that when each instance of the Service is instantiated, it begins calling that address every X seconds whenever it is free, in order to let the Client know how many Servers are available.

Maybe im missing something but it seems as though when i create a proxy, i need to know that the server is there. When dealing with alot of servers, im assuming the above would be pretty handy? or is it usual to hard code in a list into the client of all the servers you have access to?

回答1:

The typical approach to this problem is to hide your servers behind a virtual IP/load balancer, which will distribute requests across them according to your business needs. The client makes a request to the bank of servers, addressable through a single endpoint, and the load balancer determines which server instance will actually handle the request.