Wednesday, October 2, 2013

Sandbox fail due to ProcessCPUCycles

If your sandboxed code is breaking due to the process cpu cycles, you will need to do 2 things:

1) Optimization

  • Try to reduce unneeded operations.
  • Try to reduce the amount of data requested/transmitted.
  • Optimize CRUD operations.
  • Follow the good practices.



2) Increase the ProcessCPUCycles value. My suggestion is to double the original value as starting point. Keep in mind that the ProcessCPUCycles may differ between environments, so if you have a pre-production, maybe you will need to set different values in production.

This is the PS code that you will need to run.

$spCodeService = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
$cycles = $spCodeService.ResourceMeasures["ProcessCPUCycles"]
$cycles.AbsoluteLimit = 2000000000000 # VALUE
$cycles.Update()



Regards.

Sandbox too busy........

To resolve this, you should increase the default values. You will need to apply changes increasing 1 by 1... there's not a reliable way to know what are the exact values.
Execution Tiers Properties:
An execution tier is represented by the SPUserCodeExecutionTier class. Each execution tier is distinguished from the other tiers by four properties:

    ·         MaximumWorkerProcesses: This property represents the maximum number of sandboxed worker processes that can run in the tier. The default is 1. Setting this property to more than 1 causes an additional sandboxed worker process to be created (on the server that is handling the request) in the following circumstances: No existing sandboxed worker process in the tier has an application domain that is assigned to thesandboxed solution, and all existing sandboxed worker processes in the tier have reached their maximum level of application domains.
    ·         MaximumConnectionsPerProcess: This property represents the maximum number of allowed connections from a Microsoft ASP.NET worker process (w3wp.exe) to a sandboxed worker process in the tier. The default is 1.


Script to update Tier Information:
You can change the values using this PS Script  from the SharePoint console:

$uc=[Microsoft.SharePoint.Administration.SPUserCodeService]::local
$Tier = $uc.Tiers("")
$Tier.MaximumWorkerProcesses = 5
$Tier.MaximumConnectionsPerProcess = 10
$Tier.Update()


Leandro Araguas

Saturday, July 20, 2013

Event Receiver & Sandbox Solutions in Sharepoint 2010

Lately we are facing an issue in SharePoint 2010 related to an Event Receiver sandbox solution. There're a lot of holes in the documentation of MS about Sandbox, for example, there's not a reliable way to measure the resources that an specific SB solution is consuming.

Doing a little of research, we found that you can get that information directly from SQL. The best is that you have the values for each independent solution deployed as SB.

We engage MS in order to find a solution, and looks like doing some optimization of the code, we reduce the total CPU usage in 20%. The result wasn't enough, and we are still with a extreme long limit of processCPUCyles in our servers.

We are now focused in a Approval Workflow that is being called from that solution, maybe that will help.

I will keep posting the updates here.

Regards!