Sandboxed Web Part, Developer Dashboard And Resource Quota

In this article I would like to take you through the usage of:

  1. Determining the rendering time of a Sandboxed Web Part
  2. Using a Developer Dashboard
  3. Resource Quota for Sandboxed Solutions

Sandboxed Solution

A Sandboxed Solution is executed outside the IIS worker process and it is executed within the context of a site collection by a process named SPUCWorkerProcess.exe.

Developer Dashboard

A Developer Dashboard is a debugging information framework in SharePoint. It provides the diagnostic information to troubleshoot issues with page loading and performance.

Resource Quota

Sandboxed Solutions are restricted to a Resource Quota. By default the Resource Quota is 300. It means the Sandboxed Solution can take up to 300 Resource Points per day.

The Test

For the test, we are doing the following:

  1. Create a Sandboxed Solution
  2. Add a Visual Web Part
  3. Include a 10 second delay in the web part render method
  4. Deploy a Sandboxed Solution
  5. Add web part to a page
  6. Enable a Developer Dashboard
  7. View the Dashboard
  8. View the Resource Quota usage

Create Sandboxed Solution

Create a new SharePoint project.

SharePoint-1.jpg

Choose the Sandboxed Solution option.

SharePoint-2.jpg

Add a Visual Web Part

Add a new Visual Web Part.

SharePoint-3.jpg

Include 10 second delay

Open the Web Part code file and add a 10 second delay to the Page Load event.

SharePoint-4.jpg

Deploy Sandboxed Solution

Save the solution and deploy.

SharePoint-5.jpg

Add Web Part to Page

Now edit your page and add our sandboxed web part.

SharePoint-6.jpg

Save changes to the page. Note the 10 second delay involved in rendering the page due to our delay in the web part.

Enable Developer Dashboard

To view the page processing time, we need to enable the Developer Dashboard. Open SharePoint PowerShell and execute the following code.

stsadm -o setproperty -pn developer-dashboard -pv on

If you received the successfully completed message then we are good.

SharePoint-7.jpg

View Developer Dashboard

Now we are ready to view the Developer Dashboard. Open the home page and you can see it to the bottom of the page.

SharePoint-8.jpg

Note the 10 thousand millisecond request processing time and Execution Time (due to the delay in the web part).

The developer dashboard provides the following information:

  • Thread execution time
  • Number, duration, call stack information and query text of each SQL Server query generated by the page
  • Number, duration, and call stack information of each WCF call
  • URL or timer job name
  • Current user
  • Execution start time
  • Any of the preceding statistics for code enclosed by SPMonitoredScope

SharePoint-9.jpg

A Farm Solution is required to use SPMonitoredScope.

View Resource Quota Usage

Since Sandboxed Solutions are assigned a quota, we can view them using the "Site Actions" > "Site Settings" page. Choose "Solutions" from the "Galleries" category.

SharePoint-10.jpg

You will get the following page. Please note the current Resource Usage column.

SharePoint-11.jpg

SharePoint-9.jpg

To view the 15 resource monitored in Resource Quota, please visit the link.

http://msdn.microsoft.com/en-us/library/gg615462.aspx

References

http://bit.ly/16FXeAV

Summary

In this article we have explored Sandboxed Solution delay reading through the Developer Dashboard. I hope this knowledge will help you in troubleshooting real-world scenarios.