Request Management in SP2013

 

Why Request Management

SharePoint 2010 had request throttling.  That is let us say been enhanced and in SharePoint 2013 we have Request Management.

Drawbacks of SP2010 Req Throttling

It was not possible to route specific requests to specific server i.e. that kind of control was not with the admin.  For example if a particular WFE is down, the client gets server busy messages from the pool health WFE while other WFEs still were available.

Through RM we can plan to send specific requests to specific servers.  E.g. all requests of specific type like search can be sent to specific machines.

RM can help maintain farm by sending heavy requests to powerful machines.

Through RM we can identify harmful requests

RM mainly includes following 3 main components

1. Request Routing

We have something called as Routing rules to route certain requests to certain WFEs.  For e.g. an admin might decide to route all requests for .pdfs to WFE2.  Routing rules can be written to serve this kind of request.

2. Request throttling and request prioritization

If a particular WFE is heavily utilized from one particular application e.g. Outlook sync is producing lot of sync requests.  Now each machine has a health score from 0 to 10.  0 being the healthiest.  An admin might decide to stop all requests from outlook sync when the health score of WFE reaches 8.  Through RM, one can design a throttling rule which says to stop all requests from useragent *microsoftoutlook.* when the health score of the machine is 8.

3. Request load balancing

Select a WFE server to route the request based on the weighting scheme decided.

Now we need to be familiar with certain terms before understanding RM

1. Health score – We already saw this.  Every WFE can get a health score between 0 and 8.  The policy engine health rule updates the health weights and these cannot be changed by admin

2. Static weights – Each machine can be given a static weight by the admin.  These again can vary from 1 to 10, 1 being the highest.  Admin sets the static weights of the machines so that certain ones are always preferred

3. Routing weights – Routing weights uses health weights and static weights.

4. Routing Rules – Routing rules are configured by admin to route the requests of certain type to certain servers etc.

5. Throttling rules – Throttling rules are configured by admin to throttle certain kind of requests.

Routing and Throttling rules can match

Matching Parameters Methods
Url Starts With
URL Referrer Ends With
User Agent Equals
Host IP RegEx
Http Method  
Soap Action  
Custom Header  

One thing to note is Request Management is applied per web app.

How Does it Work

RM has execution groups. Execution groups contain routing rules. There are 4 execution groups.  When a request comes, rules in execution group 0 are run.  If any of the rule matches, the rest of the rules are not run.  If none in Execution group 0 matches rules of the next execution groups are run.  Each rule points to a machine pool.  Each machine pool contains few servers.  There are cmdlets to create machine pools and add servers to these.  Each machines can be given static weights by admin.  Again there are cmdlets for the same.

We need to start Request Management Service instance.  This can be done from central admin by going to services of this server.

Powershell command ‘Start-SPServiceInstance’ can also be used for the same

1. SPRequestManagementSettings

Get-SPRequestManagementSettings – gets request management settings for a particular web application

Set-SPRequestManagementSettings – sets the settings for a web app

Example

$webApp = Get-SPWebApplication https://sharepoint01/

$rmSettings = $webapp | Get-SPRequestmangementsettings

image

Set-SPRequestManagement Settings can be used to set few configurable properties like ThrottlingEnabled.

Example -

$webapp | Set-SPRequestManagementSettings -ThrottlingEnabled $True

The RequestManagementSettings object got through Get-SPRequestManagementSettings is passed to other cmdlets of RM

2. SPRoutingMachinePool

Cmdlets – Add-SPRoutingMachinePool allows to add machine servers to a pool and also create a machine pool

     Get-SPRoutingMachinePool allows to get a machine pool configuration.

Example -

Add-SPRoutingMachinePool -Name `PrimaryMachinePool' -RequestManagementSettings $rmSettings -MachineTargets "SPTaleSpin2013"

Get-SPRoutingMachinePool –RequestManagementSettings $rmSettings

3. SPRoutingMachineInfo

CmdLets – Get-SPRoutingMachineInfo gets machine info

                 Set-SPRoutingMachineInfo – allows to set properties like static weight for a particular machine.

Example

$machineInfo = Get-SPRoutingMachineInfo –Name “SP02” –RequestManagementSetting $rmSettings

Set-SPRoutingMachineInfo –Identity $machineInfo –StaticWeight 4

4. Add-SPRoutingRule and Add-SPThrottlingRule

As the name suggests these cmdlets are used to add routing and throttling rule.

Each of the routing or throttling rule needs a criteria. 

New-SPRequestManagementRuleCriteria – cmdlet lets us define a criteria.  This cmdlet has 3 params

a)Property – It can be Url, Url Referrer, UserAgent (all the parameters we saw in the table above)

b)MatchType – It can be Equal, StartsWith, Regex (all the methods we saw in the table above)

c)Value – The value of property to be matched with

Example

$criteria1 = New-SPRequestManagementRuleCriteria –Property Host –MatchType Equals –Value “www.abc.com”

Hence criteria1 is all request for host www.abc.com

Now lets create a routing rule

$webApp = Get-SPWebApplication ‘https://sp1”

$rmSettings = Get-SPRequestManagementSettings $webApp

$mp1 = Get-SPRoutingMachinePool –RequestManagementSettings $rmSettings –Name “primary machine pool”

$criteria1 = New-SPRequestManagementRuleCriteria –Property Host –MatchType Equals –Value “www.abc.com”

$rule1= Add-SPRoutingRule –RequestManagementSettings $rmSettings –Name ‘Rule for abc.com’ –Criteria $criteria1 –ExecutionGroup 0 –MachinePool $mp1

Similarly we can define throttling rule as

$criteria2 = New-SPRequestManagementRuleCriteria –Property UserAgent –MatchType Regex –Value ‘*.microsoft.outlook.*’

Add-SPThrottlingRule –Criteria criteria2 –Threshhold 8