design and development performance considerations

43
NEW ZEALAND SHAREPOIN T CONFERENCE MARCH 16+17 2011

Upload: elaine-van-bergen

Post on 29-Nov-2014

3.528 views

Category:

Documents


4 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Design and Development performance considerations

N E W Z E A L A N DSHAREPOINTCONFERENCEM A R C H 1 6 + 1 7 2 0 1 1

Page 2: Design and Development performance considerations

DESIGN AND DEVELOPMENT PERFORMANCE CONSIDERATIONS

Elaine van Bergen

Page 3: Design and Development performance considerations

ELAINE VAN BERGENARCHITECT OBS MELBOURNE

• SharePoint MVP

• Microsoft Virtual Technical Solutions Professional

• Co-organiser of Melbourne’s MOSSIG (Microsoft Office Special Interest Group) and SharePoint Saturday Melbourne

• @laneyvb on Twitter

• Blog at http://laneyvb.blogspot.com/

Dash Cache Log Dispose Querying Throttling

Page 4: Design and Development performance considerations

AGENDA

• Developer Dashboard

• Caching

• Logging

• Object Disposal

• Querying

• Throttling

Dash Cache Log Dispose Querying Throttling

Page 5: Design and Development performance considerations

HOW TO ENABLE

• Object Model

• PowerShell

• STSADM

Dash Cache Log Dispose Querying Throttling

Page 6: Design and Development performance considerations

MASTERPAGE PLACEMENT<Sharepoint:DeveloperDashboardLauncher

ID="DeveloperDashboardLauncher"

NavigateUrl="javascript:ToggleDeveloperDashboard()"

runat="server"

ImageUrl="/_layouts/images/fgimg.png"

Text="<%$Resources:wss,multipages_launchdevdashalt_text%>"

OffsetX=0

OffsetY=78

Height=16

Width=16 />

<div id="DeveloperDashboard" class="ms-developerdashboard" />

<SharePoint:DeveloperDashboard runat="server" />Dash Cache Log Dispose Querying Throttling

Page 7: Design and Development performance considerations

SPMONITORED SCOPEusing (SPMonitoredScope monitoredScope = new SPMonitoredScope("Monitor My Code"))

{ LongRunningCall(); }

SPCriticalTraceCounter.AddDataToScope(99, "What happened ?", 15, "Add additional info here");

1 Critical

4 Exception (Watson)

6 Assert

8 Warning

10 Unexpected

15 MonitorableDash Cache Log Dispose Querying Throttling

Page 8: Design and Development performance considerations

SHOW YOU SOMETHING COOLDEV DASHBOARD

Page 9: Design and Development performance considerations

DevDashVis

• http://devdashvis.

codeplex.com

Dash Cache Log Dispose Querying Throttling

Page 10: Design and Development performance considerations

TYPES OF CACHE

• Output – Generated HTML for future requests

• Object – Common objects and query results

• BLOB – Commonly requested files put on WFE disk

http://download.microsoft.com/download/7/F/0/7F069D0B-B6BD-4692-868B-E8555BB72445/SharePointServerCachesPerformance.docx

Dash Cache Log Dispose Querying Throttling

Page 11: Design and Development performance considerations

CACHING

Page 12: Design and Development performance considerations

OUTPUT

• Stores rendered aspx pages

• Enable output cache at site collection

• Time to live vs. Check for Changes

• Each page uses 2x+32 KB of memory

• Highly flexible with Cache Profiles

Dash Cache Log Dispose Querying Throttling

Page 13: Design and Development performance considerations

PROFILE OPTIONS

• Perform ACL Check

• Enabled

• Duration

• Check for changes

• Vary by custom , http header ,query string ,user rights

• Cachability

• Safe for authenticated use

• Allow writers to view cached contentDash Cache Log Dispose Querying Throttling

Page 14: Design and Development performance considerations

PROFILE OPTIONS ADVANCED

• Per page layout

• Cache profile overrides for host header site collections avavilable for:• varyByHeader

• varyByParam

• varyByCustom

• varyByRights

• cacheForEditRights

Dash Cache Log Dispose Querying Throttling

Page 15: Design and Development performance considerations

OBJECT

• Used by publishing, content by query web part, navigation, search query box, and metadata navigation

• Via code e.g. PortalSiteMapProvider

• Draft vs published = PortalSuperUserAccount and PortalSuperReaderAccount

Dash Cache Log Dispose Querying Throttling

Page 16: Design and Development performance considerations

CONFIGURING OUTPUT ACCOUNTS

• Super Reader = web policy read

• Super User = web policy full

• Not run as system

• Dedicated accounts not app pool or login

Dash Cache Log Dispose Querying Throttling

Page 17: Design and Development performance considerations

CACHE MULTIPLIER

Dash Cache Log Dispose Querying Throttling

1-10Visible with

edit permissions

11-20 Visible to

members of group x

21-30Visible to everyone

31-40Visible to everyone

Visible to super-user

Visible to super-readerVisible to super-user

Visible to super-reader

Page 18: Design and Development performance considerations

BLOB

• On disk on each WFE

• Best for infrequently changed css, js and images or large video

• Video is normally buffered from SQL on WFE adding latency, BLOB cache is nearly equivalent of IIS direct

• Adds http range support

Dash Cache Log Dispose Querying Throttling

Page 19: Design and Development performance considerations

BLOB

• Configured per web application

• Extended web app has it’s own blob cache

• Long url’s can break blob cache (server relative > 160 characters)

• Can affect and be corrupted by IIS recycle if large

• Optimised for anonymous

Dash Cache Log Dispose Querying Throttling

Page 20: Design and Development performance considerations

BLOB CACHE INVALIDATING

• Edit, Delete cached file = file removed

• Delete file not cached, delete folder, rename/delete list, change permissions, title, description, add/remove content type = all files in list removed

• Rename/delete web, add/remove permissions, change inheritance, add/update/delete roles = all files in web removed

• Delete site collection = all files in site collection removed

• Change user policy at web application = entire cache abandoned

Dash Cache Log Dispose Querying Throttling

Page 21: Design and Development performance considerations

CONFIGURING

• <BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" enabled="false"/>

• Max-Age is optional , defaults to 86400 seconds (1 day)

• Also tune the IIS app pool startup and shutdown to > 300 seconds

Dash Cache Log Dispose Querying Throttling

Page 22: Design and Development performance considerations

BRANDING STORAGE LOCATION

• SharePoint Library• User Centric

• Blob Cache can help

• Different libraries may have varied results for anonymous

• _Layouts• Default SharePoint Max Age

• Custom Virtual Directory or dedicated web app

Dash Cache Log Dispose Querying Throttling

Page 23: Design and Development performance considerations

CACHING DESIGN FOR IMAGES/CSS AND VIDEO

• MAX AGE determines when to reload

• Authors want it to change asap

• Version CSS/Image to ensure reload

• For examples Myfile1.1.css

Dash Cache Log Dispose Querying Throttling

Page 24: Design and Development performance considerations

CACHING OBJECTS VIA CODE

• Consider if object is thread safe

• SPWEB is not therefore any item with embedded web like SPSListItemCollection can cause issues

• Lock and cache to object such as datatable

Dash Cache Log Dispose Querying Throttling

Page 25: Design and Development performance considerations

private static object _lock = new object();

public void CacheData() {

DataTable oDataTable;

SPListItemCollection oListItems;

lock(_lock) {

oDataTable = (DataTable)Cache["ListItemCacheName"]; If(oDataTable == null)

{

oListItems = DoQueryToReturnItems();

oDataTable = oListItems.GetDataTable(); Cache.Add("ListItemCacheName", oDataTable, ..);

}

}

} Dash Cache Log Dispose Querying Throttling

Page 26: Design and Development performance considerations

SHOW YOU SOMETHING COOLCACHE

Page 27: Design and Development performance considerations

LOGGING

Dash Cache Log Dispose Querying Throttling

Page 28: Design and Development performance considerations

DISPOSE

• It’s complicated !

• 64 bit helps hide the problem for longer

• Not just memory, SPRequest = 1:1 SQL connection

• http://blogs.msdn.com/b/rogerla

Dash Cache Log Dispose Querying Throttling

Page 29: Design and Development performance considerations

DO NOT DISPOSESPContext.Current.Site

SPContext.Current.Web

SPContext.Site

SPContext.Web

SPControl.GetContextWeb(..)

SPControl.GetContextSite(..)

SPFeatureReceiverProperties.Feature.Parent

SPItemEventProperties.ListItem.Web

SPList.BreakRoleInheritance() Do not call list.ParentWeb.Dispose()

SPListEventProperties.Web

SPListEventProperties.List.Web

SPSite.RootWeb Problems may occur when SPContext.Web has equality to the SPContext.Web.. make sure you dispose of SPSite and it will cleanup sub webs automatically

SPSite.LockIssue

SPSite.Owner

SPSite.SecondaryContact

SPWeb.ParentWeb

SPWebEventProperties.Web

Dash Cache Log Dispose Querying Throttling

Page 30: Design and Development performance considerations

SHAREPOINT 2010 CHANGES

• Microsoft.SharePoint.WebControls.SiteAdminsitrationSelector.CurrentItem 2007 must dispose, 2010 don’t

• Event Recievers• Properties.OpenWeb() – 2007 dispose of SPWeb

• SPItemEventProperties.Web instead and no dispose

Dash Cache Log Dispose Querying Throttling

Page 31: Design and Development performance considerations

DISPOSE MONITORING

• SPDisposeCheck

• ULS Logs

• Memory Internals

• SQL Server Connections

Dash Cache Log Dispose Querying Throttling

Page 32: Design and Development performance considerations

QUERYING METHODS

• Search Object model solid performed but delayed data

• PortalSitemapProvidor if data is low and relatively static

• SPListItems GetDataTable and SPQuery for list data retrieval

• For each is the last option

http://office.microsoft.com/download/afile.aspx?AssetID=AM102377231033

Dash Cache Log Dispose Querying Throttling

Page 33: Design and Development performance considerations

CONTENT ITERATORSPQuery query = new SPQuery(); query.Query = "<Where><Eq><FieldRef Name=\"MyIndexedField\"/><Value Type=\"Text\">FieldValue</Value></Eq></Where>" + ContentIterator.ItemEnumerationOrderByNVPField;

ContentIterator ci = new ContentIterator();

ci.MaxItemsPerQuery = 500;

ci.ProcessItemsInList(query,

delegate(SPListItem item)

{

// Work on each item.

},

delegate(SPListItem item, Exception e)

{

// Handle an exception that was thrown while iterating. // Return true so that ContentIterator rethrows the exception. } );

Dash Cache Log Dispose Querying Throttling

Page 34: Design and Development performance considerations

THROTTLING TYPES

• List Throttling

• Row and Column Throttling

• Http Request

• Unique Permissions

• You can add your own

Dash Cache Log Dispose Querying Throttling

Page 35: Design and Development performance considerations

LIST THROTTLING

• Any operation that impacts x amount of items is throttled

• Default is 5000 items, beware of table locks if you change

• Overrides for auditors and administrators only in OM

• Machine admin overrides all throttle limits

• Happy hour(s)

Dash Cache Log Dispose Querying Throttling

Page 36: Design and Development performance considerations

COMMON OPERATIONS THAT ARE THROTTLED

• Create, remove, delete an indexed field

• Add, Modify indexing on field

• Delete list

• Save list as template

• Sort , Filter by non-indexed field

• Delete site

• Change field uniqueness

• Show totals

• Change list relationship state on field

• Enable disable attachments

Page 37: Design and Development performance considerations

LIST THROTTLING WITH METADATA NAV

• Retry Query with different indexed fields

• Fallback query for subset of data

• Enabled for all lists in the web once metadata navigation feature is enabled

• Just via the UI not the OM

Dash Cache Log Dispose Querying Throttling

Page 38: Design and Development performance considerations

LIST THROTTLING VIA CODE

using (SPSite site = new SPSite (“http://site”))

{

using (SPWeb web = theSite.RootWeb)

{

SPList list = web.Lists[“Listname”];

SPQuery query = new SPQuery();

query.QueryThrottleMode = SPQueryThrottleOption.Override;

//setup query here

SPListItemCollection collection = list.GetItems(query);

//do something with your data here

} Dash Cache Log Dispose Querying Throttling

Page 39: Design and Development performance considerations

HEALTH SCORE

• Health score is given back as part of the http headers X-SharePointHealthScore

• 0 is healthiest, 10 is the worst

• Office applications such as workspace use adaptive sync based on health score

• Consider use if performing high load operations remotely

Dash Cache Log Dispose Querying Throttling

Page 40: Design and Development performance considerations

HEALTH SCORE

Dash Cache Log Dispose Querying Throttling

Page 41: Design and Development performance considerations

AGENDA RECAP

• Developer Dashboard

• Caching

• Logging

• Object Disposal

• Querying

• Throttling

Dash Cache Log Dispose Querying Throttling

Page 42: Design and Development performance considerations

@[email protected]

Questions ?

Page 43: Design and Development performance considerations

Gold Sponsors

Silver Sponsors

Bronze Sponsors