Implementing Load Balancing

SharePoint 2010

Last modified: April 15, 2010

Applies to: SharePoint Foundation 2010

Service Application Framework applications are typically hosted on multiple computers and invoked from service client applications running on front-end Web servers. You must route service application proxy method invocations from the front-end Web server to an appropriate application server by using a load balancer.

SharePoint 2010 provides a simple load balancer implementation in the SPRoundRobinServiceLoadBalancer class. Service application proxies can use the built-in load balancer to route requests to the appropriate back-end service application.

The following example code shows how to create, provision, and unprovision (remove provisioning from) the load balancer.

internal SampleWebServiceApplicationProxy(
   string name,
   SampleWebServiceProxy serviceProxy,
   Uri serviceApplicationAddress)
   : base(name, serviceProxy, serviceApplicationAddress)
   // Create a new load balancer.
   m_LoadBalancer = new SPRoundRobinServiceLoadBalancer(serviceApplicationAddress);

        public override void Provision()
   // Provision the load balancer.

   // Ensure the provisioned load balancer 
   // is persisted back to the database.  

        public override void Unprovision()
   // Unprovision the load balancer.


   // Ensure the unprovisioned load balancer 
   // is persisted back to the database.