Udostępnij za pośrednictwem


Configure sandboxed solutions service tiers (SharePoint Server 2010)

 

Applies to: SharePoint Foundation 2010, SharePoint Server 2010

Based on the average amount of resources per request that sandboxed solutions use, they can be grouped into tiers in the sandboxed solutions service. A tier consists of one or more worker processes that contain one or more application domains in which sandboxed solutions run. By default, all solutions run in the sandboxed solutions service in one tier. You can configure additional tiers within the sandboxed solutions service to separate sandboxed solutions for performance, security, and reliability. For more information about tiers, see Sandboxed solutions overview (SharePoint Server 2010) and Sandbox Tiers (https://go.microsoft.com/fwlink/p/?LinkId=217145). For information about how to plan for tiers, see Plan sandboxed solutions (SharePoint Server 2010).

The sandboxed solutions service provides the environment for sandboxed solutions to run on your Microsoft SharePoint Server 2010 farm. You can use the SharePoint Central Administration Web site to start and stop the service, but you must use Windows PowerShell to configure tiers and most other features of the service.

The Sandbox Solution framework provides a mechanism for executing user-provided code outside of the IIS worker process. The Sandbox Solution framework should not be used as a mechanism for enforcing security boundaries when executing user code. Sandbox Solutions are not supported as a security boundary with user code, especially code of unknown origin. We advise against executing Sandbox Solutions of unknown origins.

In this article:

  • Configure sandboxed solutions service tiers

  • Display the sandboxed solutions service configuration settings

  • Restart the sandboxed solutions service

Configure sandboxed solutions service tiers

You can use this procedure to configure tiers for the sandboxed solutions service and to configure the worker processes, application domains, and other properties for each tier. You can use the code sample in this procedure as a stand-alone script, or you can combine it with the sample scripts in the other procedures in this article to configure the tiers and their properties, display the settings, and restart the service. For more information about the properties for tiers, see Using Execution Tiers to Protect Well-Behaved Sandboxed Solutions(https://go.microsoft.com/fwlink/p/?LinkID=220258).

To configure tiers

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.

  2. Copy the following code and paste it into a text editor, such as Notepad:

    #Initialize the SPUserCodeService variable
    $uc=[Microsoft.SharePoint.Administration.SPUserCodeService]::local
    
    #Delete any existing default tiers first
    foreach($tier in $uc.Tiers)
    {
         $tier.Delete()
    }
    $uc.Tiers.Add("Tier1")
    $uc.Tiers["Tier1"].MaximumWorkerProcesses = 5
    $uc.Tiers["Tier1"].MaximumConnectionsPerProcess = 10
    $uc.Tiers["Tier1"].MaximumAppDomainsPerProcess = 10
    $uc.Tiers["Tier1"].PriorityPerProcess = [int] ([System.Diagnostics.ProcessPriorityClass]::Normal)
    $uc.Tiers["Tier1"].ResourceMaxValue = 0.1
    $uc.Tiers["Tier1"].Update()
    
    $uc.Tiers.Add("Tier2")
    $uc.Tiers["Tier2"].MaximumWorkerProcesses = 5
    $uc.Tiers["Tier2"].MaximumConnectionsPerProcess = 10
    $uc.Tiers["Tier2"].MaximumAppDomainsPerProcess = 10
    $uc.Tiers["Tier1"].PriorityPerProcess = [int] ([System.Diagnostics.ProcessPriorityClass]::BelowNormal)
    $uc.Tiers["Tier2"].ResourceMaxValue = 10
    $uc.Tiers["Tier2"].Update()
    
  3. Save the file, naming it ConfigureTiers.ps1.

  4. On the Start menu, click All Programs.

  5. Click Microsoft SharePoint 2010 Products.

  6. Click SharePoint 2010 Management Shell.

  7. Change to the directory where you saved the file.

  8. At the Windows PowerShell command prompt, type the following command:

    ./ConfigureTiers.ps1
    
  9. Restart the SharePoint 2010 User Code Host service on the server.

Display the sandboxed solutions service configuration settings

You can use this procedure to display the tiers that have been configured for the sandboxed solutions service and to display the worker processes, application domains and other properties that are currently configured for each tier. You can append this script to the script in the previous procedure, or you can use it as a stand-alone script.

To display the existing configuration

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.

  2. Copy the following code and paste it into a text editor, such as Notepad:

    #Loop through and show the user what exactly has been created
    
    $uc=[Microsoft.SharePoint.Administration.SPUserCodeService]::Local
    
    Write-Host "The following tiers have been created"
    Write-Host "***********************************************************"
    
    foreach($tier in $uc.Tiers)
    {
         Write-Host "Tier Name: $($tier.Name)"
         Write-Host "Tier MaximumWorkerProcess: $($tier.MaximumWorkerProcesses)"
         Write-Host "Tier MaximumConnectionsPerProcess: $($tier.MaximumConnectionsPerProcess)"
         Write-Host "Tier MaximumAppDomainsPerProcess: $($tier.MaximumAppDomainsPerProcess)"
         Write-Host "Tier PriorityPerProcess: $($tier.PriorityPerProcess)"
         Write-Host "Tier ResourceMaxValue: $($tier.ResourceMaxValue)"
    
         Write-Host "***********************************************************"
    }
    
  3. Save the file, naming it DisplayTiers.ps1.

  4. On the Start menu, click All Programs.

  5. Click Microsoft SharePoint 2010 Products.

  6. Click SharePoint 2010 Management Shell.

  7. Change to the directory where you saved the file.

  8. At the Windows PowerShell command prompt, type the following command:

    ./DisplayTiers.ps1
    

Restart the sandboxed solutions service

Many of the changes that you can make to the configuration of the sandboxed solutions service take effect only after the service is restarted. This procedure creates a script that you can use to restart the sandboxed solutions service. You can append this script to other configuration scripts to automatically restart the service whenever you change its configuration.

To restart the sandboxed solutions service by using Windows PowerShell

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.

  2. Copy the following code and paste it into a text editor, such as Notepad:

    #Recycle the UserCode Service
    $server = [Microsoft.Sharepoint.Administration.SPServer]::local
    
    $userCodeServiceInstance
    $getChildMethod
    $type = $server.GetType()
    
    foreach($method in $type.GetMethods())
    {
         if( $method.Name -eq "GetChild")
         {
              $getChildMethod = $method
         }
    }
    
    $genericMethod = $getChildMethod.MakeGenericMethod([microsoft.sharepoint.administration.spusercodeserviceinstance])
    $userCodeServiceInstance = $genericMethod.Invoke($server, $null)
    $userCodeServiceInstance.Provision()
    
  3. Save the file, naming it RestartService.ps1.

  4. On the Start menu, click All Programs.

  5. Click Microsoft SharePoint 2010 Products.

  6. Click SharePoint 2010 Management Shell.

  7. Change to the directory where you saved the file.

  8. At the Windows PowerShell command prompt, type the following command:

    ./RestartService.ps1
    

See Also

Concepts

Sandboxed solutions overview (SharePoint Server 2010)
Plan sandboxed solutions (SharePoint Server 2010)
Enable sandboxed solutions on the farm (SharePoint Server 2010)
Block or unblock a sandboxed solution (SharePoint Server 2010)
Configure load balancing for sandboxed solutions (SharePoint Server 2010)
Configure resource points for sandboxed solutions (SharePoint Server 2010)