When configuring Quota templates in SharePoint 2010 you will notice that a new section is added to the page. It’s called Sandbox solutions with Code Limits and is used to put a quota on sandbox solutions so that solutions that does not work properly will be shut down and not work when it reaches the maximum daily quota. In this way we can limit sandbox solutions and protect our farm from poorly written code. As you can see on the screenshot below the values that should be specified (300 and 100 as default) are measured in points. So what is a point in this case? 

 

Microsoft has developed a way to calculate “problems”  within a solution based on a number of different metrics. To see what matrics are used you can use PowerShell and type the two following line of code in the SharePoint 2010 Management Shell: 

PS > $spCodeService = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
PS > $spCodeService.ResourceMeasures | select name
Name
----
AbnormalProcessTerminationCount
CPUExecutionTime
CriticalExceptionCount
IdlePercentProcessorTime
InvocationCount
PercentProcessorTime
ProcessCPUCycles
ProcessHandleCount
ProcessIOBytes
ProcessThreadCount
ProcessVirtualBytes
SharePointDatabaseQueryCount
SharePointDatabaseQueryTime
UnhandledExceptionCount
UnresponsiveprocessCount

This will generate a list of all the Resource Measures. Each item has a number of properties that defines how the points should be calculated. If we take a closer look to the first item by typing: 

PS > $spCodeService.ResourceMeasures["AbnormalProcessTerminationCount"]
MinimumThreshold                : 0
ResourcesPerPoint               : 1
AbsoluteLimit                   : 2
DiskSizeRequired                : 0
CanSelectForBackup              : False
CanRenameOnRestore              : False
CanSelectForRestore             : True
CanBackupRestoreAsConfiguration : True
Name                            : AbnormalProcessTerminationCount
TypeName                        : Microsoft.SharePoint.Administration.SPResourc
                                  eMeasure
DisplayName                     : AbnormalProcessTerminationCount
Id                              : 9056369d-768e-42bd-bd9c-67d810ad7936
Status                          : Online
Parent                          : SPUserCodeService Name=SPUserCodeV4
Version                         : 2410
Properties                      : {}
Farm                            : SPFarm Name=SharePoint_SP2010TestFarm_ConfigD
                                  B
UpgradedPersistedProperties     : {} 

In the above case the RecourcesPerPoint value is set to one. This means that whenever an Abnormal Process Termination occurs it will generate one “point”. You can also see that there is a AbsoluteLimit value. If any specific ResourceMeasure hits its AboluteLimit it will shut down the solution even if the daily quota of points is not reached. By typing the following you can see each ResourceMeasure’s ResourcesPerPoint and AbsoluteLimit values:

PS > $spCodeService.ResourceMeasures | select name, resourcesperpoint, absolutelimit
Name                                ResourcesPerPoint             AbsoluteLimit
----                                -----------------             -------------
AbnormalProcessTerminat...                          1                         2
CPUExecutionTime                                  200                        60
CriticalExceptionCount                             10                         3
IdlePercentProcessorTime                          100                        10
InvocationCount                                   100                       100
PercentProcessorTime                               85                       100
ProcessCPUCycles                         100000000000              100000000000
ProcessHandleCount                              10000                      5000
ProcessIOBytes                               10000000                 100000000
ProcessThreadCount                              10000                       200
ProcessVirtualBytes                        1000000000                4000000000
SharePointDatabaseQuery...                        400                       100
SharePointDatabaseQuery...                         20                        60
UnhandledExceptionCount                            50                         3
UnresponsiveprocessCount                            2                         1
 

It is possible to change the these values if you want to tweek how the points are calculated. To change the AbsoluteLimit on the AbnormalProcessTerminationCount you simply type: 

PS > $spCodeService.ResourceMeasures["AbnormalProcessTerminationCount"] `
.AbsoluteLimit = 2

If you want to change the Max Point quota for a specific site collection you can do that by typing: 

PS > (get-spsite http://SPsiteURL).Quota.UserCodeMaximumLevel = 200

Or of you want to change the quota on all site collections this is how you do. Get all site collections using the Get-SPSite cmdlet and then you pipe it to a foreach-object and then set the new value. 

PS > Get-SPSite | foreach-object {$_.Quota.UserCodeMaximumLevel = 200}


  1. [...] This post was mentioned on Twitter by Andrés Iturralde and SharePoint River, Erik Neumann. Erik Neumann said: #sharepoint Quotas and locks for sandbox solutions: When configuring Quota templates in SharePoint 2010 you will n… http://bit.ly/b7JbId [...]