NEW ZEALAND<br />SHAREPOINT<br />CONFERENCE<br />MARCH 16+17 2011<br />
Elaine van Bergen<br />Design and Development performance considerations<br />
Elaine van BergenArchitect OBS Melbourne<br />SharePoint MVP<br />Microsoft Virtual Technical Solutions Professional<br />...
Agenda<br /><ul><li>Developer Dashboard
Caching
Logging
Object Disposal
Querying
Throttling</li></li></ul><li>How to Enable<br /><ul><li>Object Model
PowerShell
STSADM</li></li></ul><li>MasterPage Placement<br /><Sharepoint:DeveloperDashboardLauncher<br />        ID="DeveloperDashbo...
SPMonitored Scope<br />using (SPMonitoredScope monitoredScope =   new SPMonitoredScope("Monitor My Code")) 	<br />{   Long...
DEV DASHBOARD<br />Show you something cool<br />
DevDashVis<br /><ul><li>http://devdashvis.</li></ul>codeplex.com<br />
Types of Cache<br /><ul><li>Output – Generated HTML for future requests
Object – Common objects and query results
BLOB – Commonly requested files put on WFE disk</li></ul>http://download.microsoft.com/download/7/F/0/7F069D0B-B6BD-4692-8...
Caching<br />
Output<br /><ul><li>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</li></li></ul><li>Profile Options<br /><ul><li>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 content</li></li></ul><li>Profile Options Advanced<br /><ul><li>Per page layout
Cache profile overrides for host header site collections avavilable for:</li></ul>varyByHeader<br />varyByParam<br />varyB...
OBJECT<br /><ul><li>Used by publishing, content by query web part, navigation, search query box, and metadata navigation
Via code e.g. PortalSiteMapProvider
Draft vs published  = PortalSuperUserAccountand PortalSuperReaderAccount</li></li></ul><li>Configuring Output Accounts<br ...
Super User = web policy full
Not run as system
Dedicated accounts not app pool or login</li></li></ul><li>Cache multiplier<br />1-10<br />Visible with edit permissions<b...
BLOB<br /><ul><li>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</li></li></ul><li>BLOB<br /><ul><li>Configured per web application
Extended web app has it’s own blob cache
Long url’s can break blob cache (server relative > 160 characters)
Upcoming SlideShare
Loading in …5
×

Design and Development performance considerations

3,291 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,291
On SlideShare
0
From Embeds
0
Number of Embeds
1,293
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Design and Development performance considerations

  1. 1. NEW ZEALAND<br />SHAREPOINT<br />CONFERENCE<br />MARCH 16+17 2011<br />
  2. 2. Elaine van Bergen<br />Design and Development performance considerations<br />
  3. 3. Elaine van BergenArchitect OBS Melbourne<br />SharePoint MVP<br />Microsoft Virtual Technical Solutions Professional<br />Co-organiser of Melbourne’s MOSSIG (Microsoft Office Special Interest Group) and SharePoint Saturday Melbourne <br />@laneyvb on Twitter<br />Blog at http://laneyvb.blogspot.com/<br />
  4. 4. Agenda<br /><ul><li>Developer Dashboard
  5. 5. Caching
  6. 6. Logging
  7. 7. Object Disposal
  8. 8. Querying
  9. 9. Throttling</li></li></ul><li>How to Enable<br /><ul><li>Object Model
  10. 10. PowerShell
  11. 11. STSADM</li></li></ul><li>MasterPage Placement<br /><Sharepoint:DeveloperDashboardLauncher<br /> ID="DeveloperDashboardLauncher"<br /> NavigateUrl="javascript:ToggleDeveloperDashboard()"<br /> runat="server"<br /> ImageUrl="/_layouts/images/fgimg.png"<br /> Text="<%$Resources:wss,multipages_launchdevdashalt_text%>"<br /> OffsetX=0<br /> OffsetY=78<br /> Height=16<br /> Width=16 /> <br /><div id="DeveloperDashboard" class="ms-developerdashboard" /> <br /><SharePoint:DeveloperDashboard runat="server" /><br />
  12. 12. SPMonitored Scope<br />using (SPMonitoredScope monitoredScope = new SPMonitoredScope("Monitor My Code")) <br />{ LongRunningCall(); }<br />SPCriticalTraceCounter.AddDataToScope(99, "What happened ?", 15, "Add additional info here");<br />1 Critical<br />4 Exception (Watson)<br />6 Assert<br />8 Warning<br />10 Unexpected<br />15 Monitorable<br />
  13. 13. DEV DASHBOARD<br />Show you something cool<br />
  14. 14. DevDashVis<br /><ul><li>http://devdashvis.</li></ul>codeplex.com<br />
  15. 15. Types of Cache<br /><ul><li>Output – Generated HTML for future requests
  16. 16. Object – Common objects and query results
  17. 17. BLOB – Commonly requested files put on WFE disk</li></ul>http://download.microsoft.com/download/7/F/0/7F069D0B-B6BD-4692-868B-E8555BB72445/SharePointServerCachesPerformance.docx<br />
  18. 18. Caching<br />
  19. 19. Output<br /><ul><li>Stores rendered aspx pages
  20. 20. Enable output cache at site collection
  21. 21. Time to live vs. Check for Changes
  22. 22. Each page uses 2x+32 KB of memory
  23. 23. Highly flexible with Cache Profiles</li></li></ul><li>Profile Options<br /><ul><li>Perform ACL Check
  24. 24. Enabled
  25. 25. Duration
  26. 26. Check for changes
  27. 27. Vary by custom , http header ,query string ,user rights
  28. 28. Cachability
  29. 29. Safe for authenticated use
  30. 30. Allow writers to view cached content</li></li></ul><li>Profile Options Advanced<br /><ul><li>Per page layout
  31. 31. Cache profile overrides for host header site collections avavilable for:</li></ul>varyByHeader<br />varyByParam<br />varyByCustom<br />varyByRights<br />cacheForEditRights<br />
  32. 32. OBJECT<br /><ul><li>Used by publishing, content by query web part, navigation, search query box, and metadata navigation
  33. 33. Via code e.g. PortalSiteMapProvider
  34. 34. Draft vs published = PortalSuperUserAccountand PortalSuperReaderAccount</li></li></ul><li>Configuring Output Accounts<br /><ul><li>Super Reader = web policy read
  35. 35. Super User = web policy full
  36. 36. Not run as system
  37. 37. Dedicated accounts not app pool or login</li></li></ul><li>Cache multiplier<br />1-10<br />Visible with edit permissions<br />11-20 Visible to members of group x <br />21-30<br />Visible to everyone<br />31-40<br />Visible to everyone<br />Visible to super-user<br />Visible to super-reader<br />Visible to super-reader<br />Visible to super-user<br />
  38. 38. BLOB<br /><ul><li>On disk on each WFE
  39. 39. Best for infrequently changed css, js and images or large video
  40. 40. Video is normally buffered from SQL on WFE adding latency, BLOB cache is nearly equivalent of IIS direct
  41. 41. Adds http range support</li></li></ul><li>BLOB<br /><ul><li>Configured per web application
  42. 42. Extended web app has it’s own blob cache
  43. 43. Long url’s can break blob cache (server relative > 160 characters)
  44. 44. Can affect and be corrupted by IIS recycle if large
  45. 45. Optimised for anonymous</li></li></ul><li>BLOB Cache inVALIDating<br /><ul><li>Edit, Delete cached file = file removed
  46. 46. Delete file not cached, delete folder, rename/delete list, change permissions, title, description, add/remove content type = all files in list removed
  47. 47. Rename/delete web, add/remove permissions, change inheritance, add/update/delete roles = all files in web removed
  48. 48. Delete site collection = all files in site collection removed
  49. 49. Change user policy at web application = entire cache abandoned</li></li></ul><li>Configuring<br /><ul><li><BlobCache location="C:blobCache" path=".(gif|jpg|png|css|js)$" maxSize="10" enabled="false"/>
  50. 50. Max-Age is optional , defaults to 86400 seconds (1 day)
  51. 51. Also tune the IIS app pool startup and shutdown to > 300 seconds</li></li></ul><li>Branding Storage Location<br /><ul><li>SharePoint Library
  52. 52. User Centric
  53. 53. Blob Cache can help
  54. 54. Different libraries may have varied results for anonymous
  55. 55. _Layouts
  56. 56. Default SharePoint Max Age
  57. 57. Custom Virtual Directory or dedicated web app</li></li></ul><li>Caching Design for Images/CSS and Video<br /><ul><li>MAX AGE determines when to reload
  58. 58. Authors want it to change asap
  59. 59. Version CSS/Image to ensure reload
  60. 60. For examples Myfile1.1.css</li></li></ul><li>CACHING OBJECTS VIA Code<br /><ul><li>Consider if object is thread safe
  61. 61. SPWEB is not therefore any item with embedded web like SPSListItemCollection can cause issues
  62. 62. Lock and cache to object such as datatable</li></li></ul><li>private static object _lock = new object(); <br />public void CacheData() { <br />DataTableoDataTable; <br />SPListItemCollectionoListItems; <br /> lock(_lock) { <br />oDataTable= (DataTable)Cache["ListItemCacheName"]; I f(oDataTable== null) <br /> { <br />oListItems= DoQueryToReturnItems(); <br />oDataTable= oListItems.GetDataTable(); Cache.Add("ListItemCacheName", oDataTable, ..); <br /> }<br /> }<br />} <br />
  63. 63. CACHE<br />Show you something cool<br />
  64. 64. Logging<br />
  65. 65. Dispose<br />It’s complicated !<br />64 bit helps hide the problem for longer<br />Not just memory, SPRequest = 1:1 SQL connection<br />http://blogs.msdn.com/b/rogerla <br />
  66. 66. Do NOT DISPOSe<br />SPContext.Current.Site<br />SPContext.Current.Web<br />SPContext.Site<br />SPContext.Web<br />SPControl.GetContextWeb(..) <br />SPControl.GetContextSite(..) <br />SPFeatureReceiverProperties.Feature.Parent<br />SPItemEventProperties.ListItem.Web<br />SPList.BreakRoleInheritance() <br />Do not call list.ParentWeb.Dispose()<br />SPListEventProperties.Web<br />SPListEventProperties.List.Web<br />SPSite.RootWeb<br />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<br />SPSite.LockIssue<br />SPSite.Owner<br />SPSite.SecondaryContact<br />SPWeb.ParentWeb<br />SPWebEventProperties.Web<br />
  67. 67. SHarePoint 2010 changes<br />Microsoft.SharePoint.WebControls.SiteAdminsitrationSelector.CurrentItem 2007 must dispose, 2010 don’t<br />Event Recievers<br />Properties.OpenWeb() – 2007 dispose of SPWeb<br />SPItemEventProperties.Web instead and no dispose<br />
  68. 68. Dispose Monitoring<br />SPDisposeCheck<br />ULS Logs<br />Memory Internals<br />SQL Server Connections<br />
  69. 69. Querying Methods<br /><ul><li>Search Object model solid performed but delayed data
  70. 70. PortalSitemapProvidor if data is low and relatively static
  71. 71. SPListItemsGetDataTable and SPQuery for list data retrieval
  72. 72. For each is the last option</li></ul>http://office.microsoft.com/download/afile.aspx?AssetID=AM102377231033 <br />
  73. 73. Content Iterator<br />SPQuery query = new SPQuery(); query.Query= "<Where><Eq><FieldRef Name="MyIndexedField"/><Value Type="Text">FieldValue</Value></Eq></Where>" + ContentIterator.ItemEnumerationOrderByNVPField; <br />ContentIterator ci = new ContentIterator();ci.MaxItemsPerQuery = 500;<br />ci.ProcessItemsInList(query, <br /> delegate(SPListItem item) <br />{ <br /> // Work on each item. <br />}, <br /> delegate(SPListItem item, Exception e) <br /> { <br /> // Handle an exception that was thrown while iterating. // Return true so that ContentIteratorrethrows the exception. } );<br />
  74. 74. Throttling Types<br /><ul><li>List Throttling
  75. 75. Row and Column Throttling
  76. 76. Http Request
  77. 77. Unique Permissions
  78. 78. You can add your own</li></li></ul><li>List Throttling<br /><ul><li>Any operation that impacts x amount of items is throttled
  79. 79. Default is 5000 items, beware of table locks if you change
  80. 80. Overrides for auditors and administrators only in OM
  81. 81. Machine admin overrides all throttle limits
  82. 82. Happy hour(s)</li></li></ul><li>Common operations THAT ARE throttled<br />Create, remove, delete an indexed field<br />Add, Modify indexing on field<br />Delete list<br />Save list as template<br />Sort , Filter by non-indexed field<br />Delete site<br />Change field uniqueness<br />Show totals<br />Change list relationship state on field<br />Enable disable attachments<br />
  83. 83. List Throttling with Metadata Nav<br /><ul><li>Retry Query with different indexed fields
  84. 84. Fallback query for subset of data
  85. 85. Enabled for all lists in the web once metadata navigation feature is enabled
  86. 86. Just via the UI not the OM</li></li></ul><li>List Throttling VIA Code<br />using (SPSite site = new SPSite (“http://site”))<br />{<br /> using (SPWeb web = theSite.RootWeb)<br />{<br />SPList list = web.Lists[“Listname”];<br />SPQuery query = new SPQuery();<br />query.QueryThrottleMode = SPQueryThrottleOption.Override;<br />//setup query here<br />SPListItemCollection collection = list.GetItems(query);<br />//do something with your data here<br />} <br />
  87. 87. Health Score<br />Health score is given back as part of the http headers X-SharePointHealthScore<br />0 is healthiest, 10 is the worst<br />Office applications such as workspace use adaptive sync based on health score<br />Consider use if performing high load operations remotely<br />
  88. 88. Health Score<br />
  89. 89. Agenda Recap<br /><ul><li>Developer Dashboard
  90. 90. Caching
  91. 91. Logging
  92. 92. Object Disposal
  93. 93. Querying
  94. 94. Throttling</li></li></ul><li>Questions ?<br />@Laneyvbelaine.vanbergen@obs.com.au<br />
  95. 95. Gold Sponsors<br />Silver Sponsors<br />Bronze Sponsors<br />

×