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.

Friend Sub New(ByVal name As String, ByVal serviceProxy As SampleWebServiceProxy, ByVal serviceApplicationAddress As Uri)
    MyBase.New(name, serviceProxy, serviceApplicationAddress)
    ' Create a load balancer.
    m_LoadBalancer = New SPRoundRobinServiceLoadBalancer(serviceApplicationAddress)

End Sub

Public Overrides Sub Provision()
    ' Provision the load balancer.


    ' Ensure the provisioned load balancer 
    ' is persisted back to the database.  
End Sub

Public Overrides Sub Unprovision()
    ' Unprovision the load balancer.


    ' Ensure the unprovisioned load balancer 
    ' is persisted back to the database.  
End Sub