Reputation: 22652
I have a WCF service hosted in a load balanced scenario. The service is hosted using IIS. There are two servers that are load balanced.
Following are the end points
in the server.
https://labA.myCompany.com:44330/MyService/InternalService.svc
https://labB.myCompany.com:44330/MyService/InternalService.svc
I keep the host base address
as
baseAddress=" https://test-LoadBalanced.myCompany.com/MyService".
This host base address is from the load balanced address.
When I type https://test-LoadBalanced.myCompany.com/MyService/InternalService.svc I can get the service page. Inside that sometimes I am getting the wsdl link for the ServerA box’s end point address and sometime Server B box’s endpoint address .
Reference
The answer to the question WCF Service Endpoints vs Host Base address says
When you host the WCF service on IIS, the base address can only be the URL to the .svc file.
Following is from WCF Addressing In Depth
Clients have no awareness of the service’s base address and have no need to support something similar on their side of the wire. As a result, you won’t find anything related to base addresses in the client-side object model or the configuration section. Clients simply choose a particular endpoint, which always comes configured with an absolute address, and that absolute address determines the address it will use during transmission.
From Load Balancing
By default, the BasicHttpBinding sends a connection HTTP header in messages with a Keep-Alive value, which enables clients to establish persistent connections to the services that support them. This configuration offers enhanced throughput because previously established connections can be reused to send subsequent messages to the same server. However, connection reuse may cause clients to become strongly associated to a specific server within the load-balanced farm, which reduces the effectiveness of round-robin load balancing. If this behavior is undesirable, HTTP Keep-Alive can be disabled on the server using the KeepAliveEnabled property with a CustomBinding or user-defined Binding.
Client
I created a client using the load balanced address. However, in the client config, the endpoint address is of the Server A box’s address; not the load balanced address.
Question
So, how the client can make use of the load-balancing performance advantage? It will be hitting the Server A always for getting the service operation, isn’t it?
Upvotes: 2
Views: 4362
Reputation: 10984
Change your client's code/config to point at the service's load balanced endpoint.
The base address is a server-only concern. It provides a way for you to specify the base URI on which all your other relative URI's are based.
If your clients send HTTP messages to your load balancer they will be forwarded to the servers. To do this just configure your clients with the service's load balancer.
It may also be wise to disable HTTP keep-alive
at the server too in order to prevent your clients from forming a sticky relationship with servers behind your LB.
Upvotes: 1
Reputation: 77285
The WSDL is only used at design time of your client application. Once the wizard has created all client classes, you can point your client application at the load balancer instead.
Upvotes: 1