Exercise 1 – Resource Points
Sandboxed Solutions were created to prevent a SharePoint solution from affecting the rest of the SharePoint site collection. SharePoint Online will throttle and even disable a solution if that solution consumes too many resources. Sandboxed Solutions monitors the resource usage of each Sandboxed Solution and assigns resource points based upon its behavior. SharePoint 2010 and SharePoint Online track metrics that contribute to the quota of a given solution. These are:
In this lab, you will be building a solution that consumes the processor for 20 seconds at a time to simulate a resource wasting solution. Normally, this task will only contribute a small amount to the resource quota since 3600 seconds (1 hour) of processor usage constitute 1 resource point by default. For the sake of this lab, you will be modifying these settings in order to demonstrate what happens when a sandboxed solution is disabled by resource usage. Changing these settings cannot be changed by users in SharePoint Online at this time, so this entire exercise will be done on-premise.
Task 1 – Shrink the CPU resource allowance
In this task, you will reduce the CPU resource allowance for sandboxed solutions. By default, any sustained CPU utilization under 100 milliseconds is not counted against your total CPU utilization since this is considered normal operation. Additionally, in order to consume 1 resource point, your sandboxed solution must use 200 seconds of CPU time. You will reduce both of these values using a PowerShell script. This script will remove the 100 millisecond minimum threshold and make one second of CPU utilization count as one resource point. The script will also lower the resource point threshold for sandbox solutions from 300 points per day to 2 points per day.
This script will change every web application’s resource quota to 2 points per day. You will be resetting them back to the default later in this lab. If you previously customized the quotas in other web applications, you will need to change them back after this lab.
Task 2 – Create a SharePoint solution that consumes resources
In this task, you will create a visual web part that consumes processor resources when a button is clicked. This will create a corresponding resource point increase in the solution gallery.
Task 3 – Test your solution
In this task, you will deploy and test your solution to SharePoint installed on premise. You will first see next to 0 resource usage, then consume the processor by clicking the button Consume the processor.
Task 4 – Monitor Resource usage
In this task, you will monitor resource usage of your solution. The amount of resource points a solution uses are calculated by the timer job Solution Resource Usage Update. This timer job is set to run every 15 minutes by default. You will use a PowerShell script to run it immediately. Resource use will be updated several minutes after the timer job completes. You will then demonstrate that the sandboxed solution is disabled.
Task 5 – Reset the CPU resource allowance