Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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.
   m_LoadBalancer.Provision();

   base.Provision();
 
   // Ensure the provisioned load balancer 
   // is persisted back to the database.  
   this.Update();
        }

        public override void Unprovision()
        {
   // Unprovision the load balancer.
   m_LoadBalancer.Unprovision();

   base.Unprovision();

   // Ensure the unprovisioned load balancer 
   // is persisted back to the database.  
   this.Update();
        }

Show:
© 2015 Microsoft